1

我已经使用 Prisma 服务作为数据库在 Heroku 中部署了 Graphql Yoga 服务器,并且我还部署了前端,它也是 Heroku 上的 nextjs 应用程序。当我尝试使用 prisma db 连接执行 upsert 操作时,它会说[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. 我在 Prisma 的 Github 问题上经历了类似的问题,找不到任何有用的东西。

prisma_db 连接:

const db = new Prisma({
  typeDefs: 'src/generated/prisma.graphql',
  endpoint: process.env.PRISMA_ENDPOINT,
  secret: process.env.PRISMA_SECRET,
  debug: true,
});

棱镜.yml:

endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
# disableAuth: true
hooks:
  post-deploy:
    - graphql get-schema -p prisma

我在 Heroku 配置变量中设置了 PRISMA_ENDPOINT 和 PRISMA_SECRET。确保 .yml 文件和数据库连接具有相同的秘密令牌。我还将秘密令牌设置为相对简单的东西,考虑一下secret123,这样也没有特殊字符。

整个错误:

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' ] }

有关信息:当我尝试从 Prisma 游乐场执行相同的 upsert 操作时,它工作正常。有人可以告诉我哪里出错了吗?提前致谢。

4

0 回答 0