I'm getting this error after the call to makeSchema:
Type 'NexusGraphQLSchema' is not assignable to type 'GraphQLSchema | undefined'.
Type 'NexusGraphQLSchema' is not assignable to type 'GraphQLSchema'.
The types returned by 'getQueryType()' are incompatible between these types.
Type 'import("/myproject/node_modules/graphql/tsutils/Maybe").default<import("/myproject/node_modules/graphql/type/definition").GraphQLObjectType<any, any, { [key: string]: any; }>>' is not assignable to type 'import("/myproject/node_modules/graphql-yoga/node_modules/graphql/tsutils/Maybe").default<import("/myproject/node_modules/graphql-yoga/node_modules/graphql/type/definition").GraphQLObjectType<any, any, { [key: string]: any; }>>'.
Type 'import("/myproject/node_modules/graphql/type/definition").GraphQLObjectType<any, any, { [key: string]: any; }>' is not assignable to type 'import("/myproject/node_modules/graphql-yoga/node_modules/graphql/type/definition").GraphQLObjectType<any, any, { [key: string]: any; }>'.
Types of property 'isTypeOf' are incompatible.
Type 'import("/myproject/node_modules/graphql/tsutils/Maybe").default<import("/myproject/node_modules/graphql/type/definition").GraphQLIsTypeOfFn<any, any>>' is not assignable to type 'import("/myproject/node_modules/graphql-yoga/node_modules/graphql/tsutils/Maybe").default<import("/myproject/node_modules/graphql-yoga/node_modules/graphql/type/definition").GraphQLIsTypeOfFn<any, any>>'.
Type 'import("/myproject/node_modules/graphql/type/definition").GraphQLIsTypeOfFn<any, any>' is not assignable to type 'import("/myproject/node_modules/graphql-yoga/node_modules/graphql/type/definition").GraphQLIsTypeOfFn<any, any>'.
Types of parameters 'info' and 'info' are incompatible.
Property 'cacheControl' is missing in type 'import("/myproject/node_modules/graphql-yoga/node_modules/graphql/type/definition").GraphQLResolveInfo' but required in type 'import("/myproject/node_modules/graphql/type/definition").GraphQLResolveInfo'.ts(2322)
index.d.ts(22, 9): 'cacheControl' is declared here.
types.d.ts(85, 5): The expected type comes from property 'schema' which is declared here on type 'Props<any, any, any>'
The call to makeSchema looks like this:
const schema = makeSchema({
nonNullDefaults: {
input: true,
output: true
},
outputs: {
typegen: path.resolve(
__dirname,
'../../node_modules/@types/nexus-typegen/index.d.ts'
)
},
plugins: [nexusPrismaPlugin()],
types: [Mutation, ...Object.values(types)]
});
Prisma Schema:
datasource db {
provider = "postgresql"
url = env("DB_CONNECTION_STRING")
}
generator client {
provider = "prisma-client-js"
}
enum Platform {
Medium
Quora
}
model Sendout {
id String @id @default(uuid())
platform Platform
uri String
}
It worked before the update to 0.8.0.
When attempting to build the project I get the additional errors:
node_modules/@types/nexus-prisma-typegen/index.d.ts:123:44 - error TS2344: Type 'MethodName' does not satisfy the constraint '"publish"'.
123 computedInputs?: LocalComputedInputs<MethodName>;
~~~~~~~~~~
node_modules/@types/nexus-prisma-typegen/index.d.ts:127:44 - error TS2344: Type 'MethodName' does not satisfy the constraint '"publish"'.
127 computedInputs?: LocalComputedInputs<MethodName>;
~~~~~~~~~~
Relevant deps:
{
"@prisma/client": "2.0.0-preview020.3",
"graphql": "^14.6.0",
"graphql-yoga": "^1.18.3",
"nexus": "^0.12.0-rc.9",
"nexus-prisma": "^0.8.0",
"prisma2": "^2.0.0-preview020.3",
"typescript": "^3.7.5"
}
Other info:
OS: Linux x86_64 @ v5.4.15
I also have this issue, are there any workarounds?
This issue is coming up because there are two copies of GraphQL installed:
/myproject/node_modules/graphql/type/definition /myproject/node_modules/graphql-yoga/node_modules/graphql/type/definitionReally, graphql should be a peerDependency of graphql-yoga, not a dependency
I seems to be fixed when adding [email protected] as a dependency in my project.
(edited)
I am using these deps:
"dependencies": {
"@nexus/schema": "^0.13.1",
"graphql": "^14.6.0",
"graphql-yoga": "^1.17.4",
"nexus-prisma": "0.12.0-next.1"
}
I get this error using the example here. The workaround using the dependencies specified above doesn't seem to work for me either.
Is there any update? It seems like the eventual goal is to replace graphql-yoga with the express server exposed by nexus but it's very early days so there's a lack of examples (specifically how to implement middleware). I'm hoping to gradually upgrade an existing project - this is my main stumbling block at the moment.
I used the same boilerplate and the dependencies listed work for me. You can check my package.json and code here for reference: https://gitlab.com/recipe-cookbook/backend . Note that you may want to regenerate your lockfile after changing dependencies by removing node_modules and package-lock.json and then running npm i again.
Thanks @radicand. Your package.json lead me to the problem - I had explicitly defined @types/graphql in devDependencies - removing this fixed it.
I removed graphql as a direct dependency from my package.json, did a rm -rf node_modules/ && rm package-lock.json && npm i && npm run generate # nexus and prisma generation
@radicand yes your package.json helped fixe it for me too. In my case I needed to add the right graphml version as an explicit dependency:
"graphql": "14.6.0", # <-- Fixed it
"tslint": "^6.1.2",
"typescript": "^3.9.2",
"@nexus/schema": "^0.13.1",
"graphql-yoga": "^1.18.3",
"nexus": "^0.21.0"
Thanks!
Relevant issue on graphql-yoga: https://github.com/prisma-labs/graphql-yoga/issues/573
@JohnLockwood Your solution worked for me, but a new issue arose from doing that as I ended up having conflicting graphql dependencies between the @nexus module and my own package.json - Have you got this issue yet or is this a known bug?
@fullstackstef - I haven't bumped into this issue.
@JohnLockwood Good to know! I think the other consideration is I'm not using graphql-yoga, but strictly nexus as a framework:
"dependencies": {
"bcryptjs": "^2.4.3",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"nexus": "^0.25.0",
"nexus-plugin-jwt-auth": "^1.2.0",
"nexus-plugin-prisma": "^0.17.0-next.7",
"nexus-plugin-shield": "^0.1.5"
}
Most helpful comment
I seems to be fixed when adding [email protected] as a dependency in my project.
(edited)
I am using these deps: