gqlgen-mongo

command module
v0.0.0-...-d6f09dd Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 7 Imported by: 0

README

gqlgen-mongo

go generate based graphql server library with mongo plugin

What is gqlgen-mongo?

gqlgen-mongo is a gqlgen generator adding a simple plugin that append bson tags for every property in a graphql struct.

Getting Started

Setup your project as described on gqlgen and then run the following command to generate the graphql server schema

go run github.com/timokoenig/gqlgen-mongo

Example

type User struct {
  ID          string        `json:"id" bson:"_id,omitempty"`
  CreatedAt   time.Time     `json:"createdAt" bson:"createdAt,omitempty"`
  Email       string        `json:"email" bson:"email,omitempty"`
}

Custom Tags

Add custom tags to your struct by adding it to the field description

type User {
  """
  The users email address
  +valid:"email"
  """
  email: String
}

This will generate the following output

type User struct {
  Email    string    `json:"email" bson:"email,omitempty" valid:"email"`
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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