Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Must provide Source. Received: null on using grpahql-jit0.4.2 #87

Open
chopraapooja opened this issue Jun 22, 2020 · 1 comment

Comments

@chopraapooja
Copy link

After adding grapqhql-jit to running express-graphql it started giving above error.
I am using Peer Dependency graphql version 14.6.0

@chopraapooja
Copy link
Author


const express = require('express')
const graphqlHTTP = require('express-graphql')
const bodyParser = require('body-parser')
const { createSchema } = require('./OTG');
const cors = require('cors');
const { compileQuery } = require("graphql-jit");
const { parse } = require('graphql');

// TODO: use better cache with invalidation 
const cache = {};

async function startServer() {
  const schema = await createSchema();
  const app = express()
  app.use(bodyParser.json())
  app.use(cors());

  app.use('/', graphqlHTTP((_, __, { query }) => {
    if (!(query in cache)) {
      const document = parse(query);
      cache[query] = compileQuery(schema, document);
    }

    return {
      graphiql: true,
      schema,
      customExecuteFn: ({ rootValue, variableValues, contextValue }) => {
        return cache[query].query(rootValue, contextValue, variableValues);
      }
    }

  }))

  app.listen(8080, () => {
    console.log(`Access graphql at http://localhost:8080`);
  })
}

// Kick things off:
startServer()```

@chopraapooja chopraapooja changed the title Error: Must provide Source. Received: undefined on using grpahql-jit0.4.2 Error: Must provide Source. Received: null on using grpahql-jit0.4.2 Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant