Understanding the GraphQL AST.

So what is an Abstract Syntax Tree?

  • parent — Otherwise known as the root — since resolvers can delegate to other resolvers this argument contains the result of the previous call
  • args — parameters requested by the user for the query
  • context — ‘global’ variable passed through the resolver chain. Useful for communicating between different layers
  • info — This is our crown jewel. This is our AST
  • fieldName: the name of the current resolver
  • fieldNodes: an array of fields left in the current selectionSet (group of fields on current object we are traversing in the tree)
  • path: Keeps track of all the parent fields that led to the current branch
  • operation: The entire query info. (this is a global field that will be the same for any resolver. Other global fields include schema, fragments, rootValueand variableValues.

So why is all this important?

  • Schema stitching
  • Custom directives
  • Enriched queries
  • Layered Abstraction
  • More backend magic!

Custom Directives

Caching

Conclusion

--

--

--

Tech Lead at Payble. Sydney, Australia. We’re hiring https://payble.com.au

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using ActionMailer with React-Redux

JWKs and node-jose

Friday Frontend: JavaScript Keeps Getting Better Edition

10 Important Javascript use !!

A Bird’s Eye View of ‘Redux’

A Guide to Using a Third Party API with React Native

Understanding React Concurrent Mode: Part 1

Trail of light beams from cars on a highway

WebSocket development with Typescript from scratch

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Hannigan

Adam Hannigan

Tech Lead at Payble. Sydney, Australia. We’re hiring https://payble.com.au

More from Medium

Sequelize and ORM magic

Example model creation in Sequelize.

Ordered collection in a relational database

A TypeScript Type-Guard for Filtering out undefined Values

Serverless Offline causes MongoDb Atlas to run out of connections