GSOC 2020
Student: Naman Kumar
Mentor: Ivan Goncharov
Organisation: GraphQL Foundation
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.
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
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.
- Writing tests for graphiql parser and achieving 100% code coverage graphql/graphiql#1654
- Adding benchmarks for graphiql parser and compare with the graphql-js parser graphql/graphiql#1612
- Testing the integration of Lexer from graphql-js into graphiql thenamankumar/graphiql#4
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.
- Building an experimental parser inside graphql-js graphql/graphql-js#2770
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.
The first 2 phases are successfully completed with the final phase of integration partially left.