Reputation: 788
I have deployed a Graphql Yoga Server in Heroku using a Prisma service as Database and I have also deploy the frontend which is a nextjs app on Heroku as well. When I try to perform a upsert operation using the prisma db connection, it fails saying [GraphQL error]: Message: Your token is invalid. It might have expired or you might be using a token from a different project., Location: undefined, Path: undefined
. I have gone through similar issues on Prisma's Github issues, couldn't find anything helpful.
prisma_db connection:
const db = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
debug: true,
});
prisma.yml:
endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
# disableAuth: true
hooks:
post-deploy:
- graphql get-schema -p prisma
I have set the PRISMA_ENDPOINT and PRISMA_SECRET in the Heroku config vars. To make sure both the .yml file and the DB connection have the same secret token. I have also set the secret token to be something relatively simple, consider secret123
, so that there are no special characters as well.
Entire Error:
2018-12-21T07:08:45.107583+00:00 app[web.1]: [GraphQL error]: Message: Your token is invalid. It might have expired or you might be using a token from a different project., Location: undefined, Path: undefined
2018-12-21T07:08:45.108037+00:00 app[web.1]: [Network error]: Error: Your token is invalid. It might have expired or you might be using a token from a different project.
2018-12-21T07:08:45.115464+00:00 app[web.1]: { Error: Your token is invalid. It might have expired or you might be using a token from a different project.
2018-12-21T07:08:45.115467+00:00 app[web.1]: at BatchedGraphQLClient.<anonymous> (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:69:35)
2018-12-21T07:08:45.115469+00:00 app[web.1]: at step (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
2018-12-21T07:08:45.115471+00:00 app[web.1]: at Object.next (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)
2018-12-21T07:08:45.115472+00:00 app[web.1]: at fulfilled (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
2018-12-21T07:08:45.115474+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2018-12-21T07:08:45.115476+00:00 app[web.1]: message:
2018-12-21T07:08:45.115478+00:00 app[web.1]: 'Your token is invalid. It might have expired or you might be using a token from a different project.',
2018-12-21T07:08:45.115480+00:00 app[web.1]: locations: [],
2018-12-21T07:08:45.115482+00:00 app[web.1]: path: [ 'upsertUser' ] }
For info: when I try to perform the same upsert operation from the Prisma playground, it works fine. Can someone please tell me where I am going wrong? Thanks in advance.
Upvotes: 1
Views: 582