title: "message": "Cannot read property 'query' of undefined",
body: <p>My environment is currently graphql-yoga with prisma.  When attempting to run queries I am faced with "Cannot read property 'query' of undefined" error.  I am assuming this is because it cannot read it from the context</p>
  
  <p>This issue came about when I was refactoring the code and setting up the Prisma connection.  I have included prisma in the context when starting the server, but it does not seem to be available anywhere. </p>
  
  <p>error</p>
  
  <pre><code>[nodemon] starting `babel-node src/index.js`
  The server is up!
  TypeError: Cannot read property 'query' of undefined
      at Object.query (G:\laragon\www\engine-backend\src\resolvers/Query.js:23:23)
      at G:\laragon\www\engine-backend\node_modules\graphql-tools\src\schemaGenerator.ts:695:54
      at next (G:\laragon\www\engine-backend\src\directives/directives.js:21:12)
      at field.resolve (G:\laragon\www\engine-backend\node_modules\graphql-tools\src\schemaGenerator.ts:692:18)
      at resolveFieldValueOrError (G:\laragon\www\engine-backend\node_modules\graphql\execution\execute.js:467:18)
      at resolveField (G:\laragon\www\engine-backend\node_modules\graphql\execution\execute.js:434:16)
      at executeFields (G:\laragon\www\engine-backend\node_modules\graphql\execution\execute.js:275:18)
      at executeOperation (G:\laragon\www\engine-backend\node_modules\graphql\execution\execute.js:219:122)
      at executeImpl (G:\laragon\www\engine-backend\node_modules\graphql\execution\execute.js:104:14)
      at Object.execute (G:\laragon\www\engine-backend\node_modules\graphql\execution\execute.js:64:63)
  </code></pre>
  
  <p>I have tried googling and searching around but it seems that I cannot find any answer. </p>
  
  <p>Here is the code</p>
  
  <pre><code>// index.js
  const { GraphQLServer } = require("graphql-yoga")
  require('dotenv').config()
  const { checkJwt } = require("./middleware/jwt")
  const { getUser } = require("./middleware/getUser")
  const { importSchema } = require("graphql-import")
  const { makeExecutableSchema } = require("graphql-tools")
  const { directiveResolvers } = require("./directives/directives")
  import { resolvers } from './resolvers/index'
  import { prisma } from './prisma/prisma'
  
  
  const schema = makeExecutableSchema({
    typeDefs: importSchema("./src/schema.graphql"),
    resolvers,
    directiveResolvers
  })
  
  
  
  const server = new GraphQLServer({
    schema,
    context: req =&gt; ({
      ...req,
      prisma
    })
  })
  
  server.express.post(
    server.options.endpoint,
    checkJwt,
    (err, req, res, next) =&gt; {
      if (err) return res.status(401).send(err.message)
      next()
    }
  )
  server.express.post(server.options.endpoint, (req, res, next) =&gt;
    getUser(req, res, next, prisma)
  )
  
  server.start({ port: process.env.PORT || 3000 }, () =&gt; {
    console.log('The server is up!')
  })
  </code></pre>
  
  <pre><code>//prisma/prisma.js
  import { Prisma } from 'prisma-binding'
  require('dotenv').config()
  import { fragmentReplacements } from '../resolvers/index'
  
  const prisma = new Prisma({
  //   fragmentReplacements: extractFragmentReplacements(resolvers),
    typeDefs: "src/generated/prisma.graphql",
    endpoint: process.env.PRISMA_ENDPOINT,
    secret: process.env.PRISMA_SECRET,
  //   debug: true,
    fragmentReplacements
  })
  
  export { prisma as default }
  </code></pre>
  
  <pre><code>// resolvers/Query.js
  const Query = {
      users (parent, args, { prisma }, info ) {
        prisma.query.users(null, info)
      },
      async leadPhones (parent, args, { prisma }, info) {
        return prisma.query.leadPhones(null, info)
      },
  
  }
  export { Query as default}
  </code></pre>