idea: use turbo-json-parse
turbo-json-parse is a JSON parser by @mafintosh that can be a lot faster by relying on the structure of the JSON to be known before-hand. Except in error cases, with GraphQL, this is always true! What do you think about integrating this module into graphql-request, for a hopefully huge performance boost?
@juliangruber you could already use it:
const client = new GraphQLClient('/api/graphql', {
async fetch(input, init): {
const response = await window.fetch(input, init);
response.json = async () => {
const json = await response.text();
return /*put your parser here*/
};
return response;
},
});
But it would be more sens to suggest this to https://github.com/dotansimha/graphql-code-generator since the generator you generate the matching parsers.
I don't think we want to bloat the package with additional dependencies, the idea of graphql-request is that it's a minimal library for calling GraphQL APIs. That said, nothing prevents you from implementing middleware that can do this for you.