Sometimes, you don't just want to expose the introspected APIs directly. This could be the case, e.g. if you're generating an API from a database, but want to decouple the client-facing API from the database-generated API.
We're automatically injecting useful fields into the Context object of the resolvers, like the
clientRequest and the
internalClient, allowing you to build really flexible solution.
As WunderGraph took already care of authentication, you can use the
user field to access the authenticated user and inject their properties into the resolver.
clientRequest field can be used to access additional headers, sent by the client, if you'd like to use them in your resolvers.
internalClient field, you can internally call into the operations you've already defined. If you're using a database-generated GraphQL Schema and got some operations defined to talk to the database, you can use WunderGraph and the internal client as a typesafe ORM.
Below, you'll find two examples, one using a schema first approach, the second one using code first.
Both schemas are automatically added to your virtual Graph.