title: Correct way to define contextType in NexusJS while using NextJS
body: <p>I trying to get Prisma and Nexus working with NextJS, but I am having some trouble defining the contextType in the GraphQL schema.</p>
  <p>I define the schema like this:</p>
  <pre class="lang-js prettyprint-override"><code>export const schema = makeSchema({
    types: [Query, User, Mutation],
    contextType: {
      module: require.resolve(&quot;./graphql/context&quot;),
      export: &quot;Context&quot;,
    },
    plugins: [nexusPrisma({ experimentalCRUD: true })],
    outputs: {
      typegen: path.join(process.cwd(), &quot;generated&quot;, &quot;nexus-typegen.ts&quot;),
      schema: path.join(process.cwd(), &quot;generated&quot;, &quot;schema.graphql&quot;),
    },
  });
  </code></pre>
  <p>The error occurs when I start the development server by running <code>npm run dev</code>. The error is as follows:</p>
  <pre><code>Module not found: Can't resolve './graphql/context'
    46 |   types: [Query, User, Mutation],
    47 |   contextType: {
  &gt; 48 |     module: require.resolve(&quot;./graphql/context&quot;),
       |            ^
    49 |     export: &quot;Context&quot;,
    50 |   },
    51 |   plugins: [nexusPrisma({ experimentalCRUD: true })],
  </code></pre>
  <p>This is the <code>context.ts</code> file:</p>
  <pre class="lang-js prettyprint-override"><code>import { PrismaClient } from &quot;@prisma/client&quot;;
  
  const prisma = new PrismaClient();
  
  export interface Context {
    prisma: PrismaClient;
  }
  
  export function createContext(): Context {
    return { prisma };
  }
  </code></pre>
  <p>My dependencies are these:</p>
  <pre class="lang-json prettyprint-override"><code>  &quot;dependencies&quot;: {
      &quot;@prisma/client&quot;: &quot;^2.13.1&quot;,
      &quot;apollo-server-micro&quot;: &quot;^2.19.1&quot;,
      &quot;next&quot;: &quot;latest&quot;,
      &quot;nexus&quot;: &quot;^1.0.0&quot;,
      &quot;nexus-plugin-prisma&quot;: &quot;^0.27.0&quot;,
      &quot;react&quot;: &quot;^16.12.0&quot;,
      &quot;react-dom&quot;: &quot;^16.12.0&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@prisma/cli&quot;: &quot;^2.13.1&quot;,
      &quot;@types/node&quot;: &quot;^12.12.21&quot;,
      &quot;@types/react&quot;: &quot;^16.9.16&quot;,
      &quot;@types/react-dom&quot;: &quot;^16.9.4&quot;,
      &quot;typescript&quot;: &quot;^4.1.3&quot;
    },
  </code></pre>
  <p>I have been trying to look for a solution, but for now I am stuck. I think it might have something to do with <code>NextJS</code> and its Webpack configs, but I have absolutely no knowledge about those so I don't really know what to try.</p>
  <p>Any help is appreciated.</p>
  <p>Project tree:</p>
  <pre><code>root
  ├─ generated
  │  ├─ nexus-typegen.ts
  │  └─ schema.graphql
  ├─ graphql
  │  ├─ context.ts
  │  └─ schema.ts
  ├─ interfaces
  │  └─ index.ts
  ├─ next-env.d.ts
  ├─ package-lock.json
  ├─ package.json
  ├─ pages
  │  ├─ api
  │  │  ├─ graphql.ts
  ├─ prisma
  │  └─ schema.prisma
  ├─ tsconfig.json
  </code></pre>