Go to file
2024-11-29 15:29:38 +01:00
.gitignore initial 2024-11-29 15:29:38 +01:00
go.mod initial 2024-11-29 15:29:38 +01:00
go.sum initial 2024-11-29 15:29:38 +01:00
README.md initial 2024-11-29 15:29:38 +01:00
xid.go initial 2024-11-29 15:29:38 +01:00

xidgql

xid graphql gqlgen marshaller and unmarshaller also in combination with ent.

In gqlgen.yml

models:
  ID:
    model:
      - code.icod.de/dalu/xidgql/xidgql.ID

as an ID field in an ent schema

package schema

import (
	"github.com/rs/xid"
)

// Fields of the Model.
func (Model) Fields() []ent.Field {
	return []ent.Field{
		field.String("id").
			GoType(xid.ID{}).
			DefaultFunc(xid.New).
			Annotations(
			    entsql.Annotation{Size: 12},
			).
			Unique(),
	}
}