Hi all, question about prisma 1 After I edit my *s...
# orm-help
g
Hi all, question about prisma 1 After I edit my schema.graphql file, do I need to run prisma deploy again? If so, why is it that after I run it says the service is up to date. This is a problem that has always been haunting me and I was never able to understand this workflow correctly) (the one that is fed to graphqlYoga when creating a GraphQLServer object) GraphQLServer({ typeDefs: './src/schema.graphql' ...
r
Hey @Gabriel Oliveira 👋
prisma deploy
would only be required if you changed the
datamodel.graphql
file that contains your DB tables. So changing your user facing
schema.graphql
should just work fine when you reload your Node app.
g
Thank you for the clarification @Ryan
💯 1
So if I have a mutation input called UserUpdateInput and then I have added a new property to that input so I can pass new data into my mutation, would it make sense to get an error after adding this property there, and there only?
Copy code
Server is up and running
[GraphQL error]: Message: Variable '$_v0_data' expected value of type 'UserUpdateInput!' but got: {"userId":"null","name":"grf3 2","email":"<mailto:grf3@grf.com|grf3@grf.com>","phone":"+148996814365"}. Reason: 'userId' Field 'userId' is not defined in the input type 'UserUpdateInput'. (line 1, column 11):
mutation ($_v0_data: UserUpdateInput!, $_v1_where: UserWhereUniqueInput!) {
          ^, Location: [object Object], Path: undefined
[Network error]: Error: Variable '$_v0_data' expected value of type 'UserUpdateInput!' but got: {"userId":"null","name":"grf3 2","email":"<mailto:grf3@grf.com|grf3@grf.com>","phone":"+148996814365"}. Reason: 'userId' Field 'userId' is not defined in the input type 'UserUpdateInput'. (line 1, column 11):
mutation ($_v0_data: UserUpdateInput!, $_v1_where: UserWhereUniqueInput!) {
          ^
Error: Variable '$_v0_data' expected value of type 'UserUpdateInput!' but got: {"userId":"null","name":"grf3 2","email":"<mailto:grf3@grf.com|grf3@grf.com>","phone":"+148996814365"}. Reason: 'userId' Field 'userId' is not defined in the input type 'UserUpdateInput'. (line 1, column 11):
mutation ($_v0_data: UserUpdateInput!, $_v1_where: UserWhereUniqueInput!) {
          ^
    at BatchedGraphQLClient.<anonymous> (/home/grf/projects/backend-telemedcan/telemedcan/node_modules/http-link-dataloader/src/BatchedGraphQLClient.ts:74:13)
    at step (/home/grf/projects/backend-telemedcan/telemedcan/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
    at Object.next (/home/grf/projects/backend-telemedcan/telemedcan/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)
    at fulfilled (/home/grf/projects/backend-telemedcan/telemedcan/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
r
If you have added that to the
UserUpdateInput
(here it’s complaining about
userId
) then it should not throw an error. I assume that you are adding these manually to your
schema.graphql
and not using Nexus?
g
@Ryan exactly, adding manually, and not usgin Nexus, btw just to confirm, this is prisma 1
Hey @Ryan I have added the main project files to this location, would you care to have quick look? https://drive.google.com/drive/folders/1XrjMBN2MGDCP-yqYrSvvBol7DJmggMIt?usp=sharing
r
This doesn’t have any
package.json
. I would need that to check it on my end
g
Done, added the package.json, same link
Just an update on this, which I found odd and interesting at the same time. I have purposefully deleted the property I'm trying to add (userId) from the UserUpdateInput (prisma.graphql file) and this is the error I've got:
Error: Variable "$_v0_data" got invalid value {"userId":"ckgjxrrd6000o0801qifmvgyj","name":"grf3 32","email":"<mailto:grf3@grf.com|grf3@grf.com>","phone":"<tel:+148996814365|+148996814365>"}; Field "userId" is not defined by type UserUpdateInput.
Adding this property back in, the error comes back to the one I mentioned above when starting this thread. Now if I remove this property from the other file, schema.graphql, on UpdateUserInput, I get the error below, but this time the error comes in the response of the http post for the graqhql query:
{"errors":[{"message":"Field \"userId\" is not defined by type UpdateUserInput.","locations":[{"line":4,"column":9}]}]}
This tells me that, the changes are being accounted for, like you mentioned @Ryan when changing the schema.graphl, and obviously prima.graphql too, theres no need to run any prisma CLI command, just reload the app. But the error I have added to the first post of this thread still persists and it's really boggling my mind... Also, I wonder if there is a better way to debug this (I'm assuming this is not a bug on prisma or any other module/package though), I'm quite stuck right now with this error
Hi @Ryan how's it going? Did you have a chance to have a look at this situation above? More specifically this message below?
Copy code
Reason: 'userId' Field 'userId' is not defined in the input type 'UserUpdateInput'. (line 1, column 11):
I still can't wrap my head around the relation between what I did (adding a new field to a mutation) and this message saying that the field does not exist in that Input when in fact it does. I wonder if I can dig more into this error by getting more detailed error information, when running the query, or finding a way to intercept those calls in a debug state in vscode etc... anything you would recommend?
r
Hey @Gabriel Oliveira not yet, I’ll setup a Prisma server and check that today 🙂
g
Ty very much Ryan 🙏
r
I cannot run the
dev
command. Could you provide me all the files required to run the project?