xidgql/README.md

34 lines
499 B
Markdown
Raw Permalink Normal View History

2024-11-29 15:29:38 +01:00
# xidgql
xid graphql gqlgen marshaller and unmarshaller also in combination with ent.
In gqlgen.yml
```yaml
models:
ID:
model:
- code.icod.de/dalu/xidgql/xidgql.ID
```
as an ID field in an ent schema
```go
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(),
}
}
```