I get this error whenever I try to hookup Prisma/N...
# graphql-nexus
a
I get this error whenever I try to hookup Prisma/Nexus to my NextJS app.
Copy code
TypeError: xs.reduce is not a function
    at Object.exports.indexBy (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/utils.js:81:19)
    at new DmmfDocument (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/dmmf/DmmfDocument.js:18:38)
    at Object.exports.getTransformedDmmf (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/dmmf/transformer.js:16:68)
    at new SchemaBuilder (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/builder.js:135:24)
    at Object.build (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/builder.js:76:21)
    at Object.onInstall (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/plugin.js:47:78)
    at /Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:299:52
    at Array.forEach (<anonymous>)
    at SchemaBuilder.beforeWalkTypes (/Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:293:22)
    at SchemaBuilder.getFinalTypeMap (/Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:375:14)
I got it all working with ApolloServer/ApolloClient/@nexus/schema. When I went to add Prisma support with 'nexus-plugin-prisma' I keep getting the above error.
The
schema.ts
file looks like this.
Copy code
import { makeSchema, queryType } from '@nexus/schema'
import { nexusPrisma } from 'nexus-plugin-prisma'
import path from 'path'

const Query = queryType({
  definition(t) {
    t.string('name', () => 'Adam Tak')
  },
})

const types = { Query }

export const schema = makeSchema({
  types,
  plugins: [nexusPrisma()],
  outputs: {
    typegen: path.join(process.cwd(), 'pages', 'api', 'nexus-typegen.ts'),
    schema: path.join(process.cwd(), 'pages', 'api', 'schema.graphql'),
  },
  typegenAutoConfig: {
    contextType: 'Context.Context',
    sources: [
      {
        source: '@prisma/client',
        alias: 'prisma',
      },
      {
        source: require.resolve('./context'),
        alias: 'Context',
      },
    ],
  },
})
It has to do with the nexusPrisma plugin. Whenever I remove it, the app runs without error.
👍 1
👀 1
m
Because
nexus-plugin-prisma
is not compatible with 2.10.0 (cf. https://github.com/graphql-nexus/nexus-plugin-prisma/pull/913)
👍 1
d
The PR related to that issue has now been merged so hopefully we’ll see a new version of
nexus-plugin-prisma
soon.
👍 1
a
Hopefully before my project deadline 😅 It's no bid deal since I'm just working on a simple app to learn with but I would like to finish it up by 7pm today so I can showcase it to my group.
@weakky Thanks for the fix mate!