How it works...
The cards.go file defines a card object and initializes the base deck in a global variable called cards. This state could also be held in long-term storage such as a database. We then define CardType in types.go that allows graphql to resolve card objects to responses. Next, we jump into resolve.go, where we define how to filter cards by value and type. This Resolve function will be used by the final schema, which is defined in schema.go.
For example, you would modify the Resolve function in this recipe in order to retrieve data from a database. Lastly, we load the schema and run a query against it. It's a small modification to mount our schema onto a rest endpoint, but for brevity, this recipe just runs a hardcoded query. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access