Huy's Notes
Generate GraphQL resolvers dynamically from Schema

Generate GraphQL resolvers dynamically from Schema

For a GraphQL API to work, you need:

  • Schema of the data
  • Resolvers

Schema is very easy to generate dynamically, there are a lot of tools to do so, for example Wamart's JSON to GraphQL generator

It's trickier to generate resolvers dynamically, but once you know the structure of the data, it become doable.

One approach is, iterate thru the structure of the data, for each field, create a function that takes it's field name or path and search on the actual data source for the relevant information.

Refer: JSON GraphQL Server

Referred in


If you think this note resonated, be it positive or negative, please feel free to send me an email and we can talk.