How to use the graphql-jit.isCompiledQuery function in graphql-jit

To help you get started, we’ve selected a few graphql-jit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github boopathi / try-graphql-jit / src / worker.ts View on Github external
// TODO
    // DANGEROUS
    // UNSAFE
    // Never save user's query.
    // This is only for demonstration
    const resolvers = new Function(...args, body).call({});

    const execSchema = makeExecutableSchema({
      typeDefs: schema,
      resolvers
    });

    const compileStart = performance.now();

    const compiledQuery = compileQuery(execSchema, parse(query), undefined, {debug: true} as any);
    if (!isCompiledQuery(compiledQuery)) {
      return {
        compiledQuery: "",
        executionResult: JSON.stringify(compiledQuery, null, 2)
      };
    }
    const compileTime = performance.now() - compileStart;

    const execStart = performance.now();
    const executionResult = await compiledQuery.query({}, {}, {});
    const executeTime = performance.now() - execStart;

    return {
      compiledQuery: prettier.format((compiledQuery as any).__DO_NOT_USE_THIS_OR_YOU_WILL_BE_FIRED_compilation,
        { parser: "babel", plugins: [babylonParser], printWidth: 80 }
      ),
      executionResult: JSON.stringify(

graphql-jit

GraphQL JIT Compiler to JS

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis

Similar packages