Closed wuzhuzhu closed 5 years ago
Thanks a lot for reporting this @wuzhuzhu! Can you please provide a minimal reproduction repo? We'll look into this asap!
Here it is possible to reproduce https://github.com/graphql-boilerplates/typescript-graphql-server.git
@wuzhuzhu @overpod I just tried to reproduce the problem, but couldn't.
Can you share a repo with the exact app & the query you're trying to execute?
Note that you should replace prepare
with codegen
.
Here I did the necessary steps to get it running with the basic example & prisma-binding@2:
https://github.com/graphql-boilerplates/typescript-graphql-server/compare/prisma-binding2
You can see the branch here: https://github.com/graphql-boilerplates/typescript-graphql-server/tree/prisma-binding2/basic
Had the same problem with an typescript-prisma project after upgrading to prisma-binding@2.0.0
Can confirm that switching the config in prisma.yml and .graphqlconfig.yml and running prisma deploy
fixed it for me.
For reference:
./database/prisma.yml
# endpoint, datamodel, secret and everything else as before...
# only changes in the hooks part
# Download the GraphQL schema of the Prisma API into
# `src/generated/prisma.graphql` (as specfied in `.graphqlconfig.yml`).
# Then generate the corresponding TypeScript definitions into
# `src/generated/prisma.ts` (also specfied in `.graphqlconfig.yml`)
# with `graphql prepare` .
hooks:
post-deploy:
- graphql get-schema
- graphql codegen
./.graphqlconfig.yml
projects:
app:
schemaPath: "src/schema.graphql"
extensions:
endpoints:
default: "http://localhost:4000"
database:
schemaPath: "src/generated/prisma.graphql"
extensions:
prisma: database/prisma.yml
codegen:
output:
binding: src/generated/prisma.ts
generator: prisma-binding
language: typescript
@kriswep @timsuchanek - Unfortunately this did not work for me :( The only thing based on this snippet that I have that is different is I am using plain javascript instead of typescript.
I have had issues with the hooks running as well - see here: https://github.com/graphcool/prisma-binding/issues/164 so to make sure the hooks ran (graphql get-schema && graphql codegen) - I put it in my npm script after just to make sure. Still get the same error
This is a show stopper for me. I have to roll back to 1.5.19 (which seems to work fine with prisma 1.8.3) until this is resolved or my project is in jeopardy :(
I saw a similar issue (without prisma-binding
), and came to a solution after a bit of digging. It may or not be related to what you guys are seeing.
The cause (for me at least) was a breaking change in the graphql-binding
API in v2.
This worked with v1.2.5:
binding.mutation.createUser(args, context, info);
but throws a Cannot convert undefined or null to object
error in v2.
It looks like the error is coming from graphql-tools
as it tries to pull fragment definitions from the passed in GraphQLResolveInfo
object. The problem is, the object its trying to pull fragments from is actually the context
object, which has no fragments, and so graphql-tools
throws the error as it tries to iterate over the keys of an undefined object.
Version 2 of graphql-binding
changed the API, and now the context
has to be passed in differently. This is what works now:
binding.mutation.createUser(args, info, { context });
If you upgraded to v2 of graphql-binding
and didn't update your code, you are likely passing in context
in place of info
.
@adamkl : Were you using yarn link
or npm link
with graphql-tools
by any chance, otherwise, you should not have seen that issue?
Generally, we deployed a release today that makes graphql codegen
more robust.
Please install the new cli via npm install -g graphql-cli
and try the graphql codegen
command.
Note that with prisma-binding
1.x, we need to use graphql prepare
and with prisma-binding
2.x, we need to use graphql codegen
Thanks!
Having the same issue and changing from graphql prepare
to graphql codgen
did not work.
Here's my package.json:
{
"name": "entr-server",
"scripts": {
"start": "node dist/index.js",
"start:local": "node -r dotenv/config dist/index.js",
"start:nodemon": "nodemon -e ts,graphql -x ts-node -r dotenv/config src/index.ts",
"dev": "npm-run-all --parallel start:nodemon playground",
"playground": "graphql playground",
"build": "rm -rf dist && graphql codegen && tsc",
"deploy:prod": "yarn prisma:login && yarn prisma:deploy:prod && yarn yoga:deploy:prod",
"prisma:deploy": "prisma deploy",
"prisma:deploy:prod": "prisma deploy -e .env.prod",
"prisma:login": "prisma login --key {CENSORED}",
"prisma:token": "prisma token",
"prisma:token:prod": "prisma token -e .env.prod",
"prisma:export:prod": "prisma export --path database/exports/export -e .env.prod",
"prisma:import": "prisma import --data database/exports/export.zip",
"yoga:deploy:prod": "yarn build && up deploy production",
"danger:local:nuke": "prisma local nuke",
"danger:prod:reset": "prisma reset -e .env.prod",
"types:generate:flow": "apollo-codegen generate queries/*.graphql --schema schema.json --target flow --output generated-types/operation-result-types.flow.js"
},
"dependencies": {
"accept-language-parser": "^1.5.0",
"email-templates": "^3.6.0",
"express-jwt": "^5.3.1",
"graphql-middleware-sentry": "^1.0.1",
"graphql-tools": "^3.0.2",
"graphql-yoga": "1.14.7",
"isomorphic-fetch": "^2.2.1",
"jsonwebtoken": "^8.2.1",
"jwks-rsa": "^1.2.1",
"luxon": "^1.2.0",
"node-fetch": "^2.1.2",
"prisma-binding": "^2.0.2",
"ramda": "^0.25.0"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.1",
"@types/email-templates": "^3.5.0",
"@types/luxon": "^0.5.2",
"dotenv": "^5.0.1",
"graphql-cli": "2.16.2",
"nodemon": "^1.17.3",
"npm-run-all": "4.1.2",
"prisma": "^1.9.0",
"ts-node": "5.0.1",
"typescript": "2.8.1"
},
"prettier": {
"semi": false,
"trailingComma": "all"
}
}
endpoint: ${env:PRISMA_ENDPOINT}
secret: ${env:PRISMA_MANAGEMENT_API_SECRET}
cluster: ${env:PRISMA_CLUSTER}
datamodel:
- datamodel/types.graphql
- datamodel/enums.graphql
seed:
import: exports/export.zip
hooks:
post-deploy:
- echo "Deployment finished"
- graphql get-schema --project database
- graphql codegen
This is my second try and i reverted back to older versions of these packages.
@harrisrobin : Can you please share your .graphqlconfig
file? It should have codegen
extension for graphql codegen
command to work as expected.
Did you already follow the upgrade guide from 1.x to 2.x?
I have the same problem , when I run a mutation with "prisma-binding": "2.1.1"
Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at /Users/fabien/Projects/course/api/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:63:112
I followed the upgrade guide. What do I do with the prisma.js file generated ?
codegen:
- generator: prisma-binding
language: javascript
output:
binding: src/generated/prisma.js
.graphqlconfig.yml
projects:
app:
schemaPath: "src/schema.graphql"
extensions:
endpoints:
default: "http://localhost:4000"
prisma:
schemaPath: "src/generated/prisma.graphql"
extensions:
prisma: database/prisma.yml
database:
schemaPath: "src/generated/prisma.graphql"
extensions:
prisma: database/prisma.yml
prisma.yml
hooks:
post-deploy:
- echo "Deployment finished"
- graphql get-schema --project prisma
- graphql codegen
Then I run prisma deploy
Thank you,
Potential reproduction - https://github.com/divyenduz/prisma-binding-162. Created with help from @zgababa. Needs validation.
My mistake ! It was an error in the call of a function. Here :
await ctx.db.mutation.updateCart({ where: { id: replaceByTheCartId } }, {
data: {
duration: 8,
},
}, info);
I put extra brackets between where and data but this is the same object. It should be :
await ctx.db.mutation.updateCart({
where: { id: replaceByTheCartId },
data: {
duration: 8,
},
}, info);
Hey 👋, I believe this issue is no longer in sync with the current version of prisma-binding
. In need for gaining a better overview of the issues facing the current version, I'll close it.
Feel free to reopen the issue if you believe we should further discuss its content. 🙂
All previous working query down when upgrade prisma-binding to 2.0.0 from 1.5.19. Err: