34 lines
499 B
Markdown
34 lines
499 B
Markdown
# 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(),
|
|
}
|
|
}
|
|
```
|