Skip to content

dsykes16/xidgql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About:

Just a tiny shim to pass gqlgen's calls to MarshalID and UnmarshalID along to github.com/rs/xid for deserialization. Used with Ent this results in properly generated, statically typed code with no weirdness.

Usage:

In gqlgen.yml:

models:
  ID:
    model:
      - github.com/dsykes16/xidgql.ID

Example Ent Schema/Mixin:

package schema

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

type XidMixin struct {
    mixin.Schema
}

func (XidMixin) Fields() []ent.Field {
    return []ent.Field{
        field.String("id").
            Immutable().
            Unique().
            GoType(xid.ID{}).
            DefaultFunc(xid.New),
    }
}

About

xid shim for gqlgen on ent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages