Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created September 6, 2021 18:12
Show Gist options
  • Save percybolmer/b3178995cd5405ede82f10e3fc851544 to your computer and use it in GitHub Desktop.
Save percybolmer/b3178995cd5405ede82f10e3fc851544 to your computer and use it in GitHub Desktop.
Graphql
package schemas
import "github.com/graphql-go/graphql"
// GopherType is the gopher graphQL Object that we will send on queries
// Here we define the structure of the gopher
// This has to match the STRUCT tags that are sent out later
var GopherType = graphql.NewObject(graphql.ObjectConfig{
Name: "Gopher",
// Fields is the field values to declare the structure of the object
Fields: graphql.Fields{
"id": &graphql.Field{
Type: graphql.ID,
Description: "The ID that is used to identify unique gophers",
},
"name": &graphql.Field{
Type: graphql.String,
Description: "The name of the gopher",
},
"hired": &graphql.Field{
Type: graphql.Boolean,
Description: "True if the Gopher is employeed",
},
"profession": &graphql.Field{
Type: graphql.String,
Description: "The gophers last/current profession",
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment