Supabase Blog

How pg_graphql works

thumbnail
  1. Introduction to pg_graphql
  • Explains what pg_graphql is and its purpose in serving GraphQL requests.
  1. Life of a GraphQL Request
  • Describes the process of handling a GraphQL request in pg_graphql.
  • Begins with the tokenization phase, where the request is broken down into lexical tokens.
  • Explains how the tokenizer identifies the start and end of each token based on the grammar rules.
  • Highlights the use of lookahead to determine the next token to be parsed.
  1. Parser
  • Introduces the role of the parser in interpreting the tokens and constructing the Abstract Syntax Tree (AST) for the request.
  • Shows how the parser uses the grammar rules to determine the structure and relationships within the AST.
  • Emphasizes the use of lookahead to guide the parsing process.
  1. Abstract Syntax Tree (AST)
  • Defines what an AST is in pg_graphql and how it is represented using Rust structs and enums.
  • Provides examples of AST nodes, such as types and fields, implemented as structs.
  • Discusses the importance of a valid AST for query execution.
  1. Validation
  • Elaborates on the need for validation after parsing the request into an AST.
  • Explains that a valid AST does not guarantee the query's executability.
  • Presents an example to illustrate potential issues and the importance of validation.

Conclusion

  • Summarizes the key points discussed in the document regarding the inner workings of pg_graphql in handling GraphQL requests.