graphql-request icon indicating copy to clipboard operation
graphql-request copied to clipboard

idea: use turbo-json-parse

Open juliangruber opened this issue 7 years ago • 1 comments

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 avatar Sep 29 '18 08:09 juliangruber

@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.

lanwin avatar Nov 06 '20 09:11 lanwin

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.

jonkoops avatar Nov 05 '23 10:11 jonkoops