Skip to content

Instantly share code, notes, and snippets.

@thenamankumar
Last active August 31, 2020 08:55
Show Gist options
  • Save thenamankumar/e7708b4bdc82a1e35817625aaf280f81 to your computer and use it in GitHub Desktop.
Save thenamankumar/e7708b4bdc82a1e35817625aaf280f81 to your computer and use it in GitHub Desktop.
The Final Evaluation progress report for GSOC 2020 by Naman Kumar under GraphQL Foundation

Adding streaming support and error recovery to reference GraphQL parser

GSOC 2020

Student: Naman Kumar

Mentor: Ivan Goncharov

Organisation: GraphQL Foundation

Goal

The goal of this project was to bring error recovery and streaming support in the graphql reference parser while maintaining the code readability, spec compliance and parser performance. This will enable this parser to be used by IDE like applications such as CodeMirror and GraphiQL. This project will also cover the migration of GraphiQL, GraphQL LSP server and CodeMirror Graphql to use the updated graphql reference parser.

Project

After the project planning, Ivan and me broken down the whole migration process of adding the new capabilities to the graphql-js reference parser into 3 phases.

  • Explore & Measure
  • Build
  • Integrate

Explore & Measure

This phase constitutes understanding the current implementation of graphiql parser and listing the requirements to integrate graphql-js parser with it. It also included increasing our confidence for doing changes by introducing tests.

Build

Based on the learning from the previous phase, we decided to build a separate experimental parser inside graphql-js which supports the requirements for a state-full incremental parser which can be used by IDEs such as graphiql itself. This parser was a generic engine which takes grammar rules in json format and parses the source string based on it. It emits a single token in each iteration and updates the state object.

Integrate

The final step was to integrate the newly build experimental graphql parser with the graphiql. The work is partially complete.

  • Write a wrapper over experimental parser to support the API required by codemirror. graphql/graphiql#1653
  • Support syntax highlighting with the new parser integration. graphql/graphiql#1653
  • Support auto suggestions with the new parser integration.

Conclusion

The first 2 phases are successfully completed with the final phase of integration partially left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment