What is AST in graphql ? I am using graphql-js. How does it help with anything?
Nothing in any documentation seems to explain what AST is
As Stephen Schneider puts in 'The GraphQL AST— Dawn of a schema', an AST is just a 'fancy way of saying heavily nested objects'. It is a structure that is commonly used in compilers to parse the code we write, converting it into a tree structure that we can traverse programmatically.
AST stands for Abstract Syntax Tree, which is a potent tool of the Python programming language. It allows us to interact with the Python code itself and can modify it.
There are three types of operations that GraphQL models: query – a read‐only fetch. mutation – a write followed by a fetch. subscription – a long‐lived request that fetches data in response to source events.
Directives are a playground for both GraphQL server implementers and end users alike. GraphQL server implementers can develop features not currently supported by the spec, and users can develop features not yet implemented by the GraphQL server. Directives' unregulated nature is a feature, not a bug.
GraphQL is two things:
When a GraphQL server receives a query to process it generally comes in as a single String. This string must be split into meaningful sub-strings (tokenization) and parsed into a representation that the machine understands. This representation is called an abstract syntax tree, or AST.
When GraphQL Processes the query, it walks the tree executing each part against the schema.
Converting raw strings to an AST is the first step of every compiler from C++ to Chrome's JavaScript's VM to Babel.
As for what GraphQL does and how it helps, here is a video that may explain it in a bit more detail. https://www.youtube.com/watch?v=PmWho45WmQY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With