Something worth pointing out is that the GraphQL and Go type systems have some pretty glaring differences, and, at least for me, it can be hard to know which mental model to reason with when working with Go code generated from a GraphQL schema. For instance, GraphQL requires explicitly stating that a type implements an interface in order for it to be used as that interface type.
Here's a list of type system differences:
- Unions exist in GraphQL, but not Go, so they are somewhat mocked through Go interfaces
- The
Is{UnionName}()
signpost functions leverage the Go compiler to help alleviate some of the confusion here - Without the signposts, a programmer implementing a query resolver would need likely need to jump to the GraphQL schema to figure out what types are included in the union
- The
- Interfaces in GraphQL differ from Go interfaces in two key ways
- A GraphQL interface definition includes only fields, where Go interfaces contain methods
- Getter functions are generated to preserve the