xidgql

package module
v0.0.0-...-54b6c4c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2023 License: Unlicense Imports: 5 Imported by: 0

README

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),
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalID

func MarshalID(id xid.ID) graphql.Marshaler

func UnmarshalID

func UnmarshalID(v interface{}) (id xid.ID, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL