mongoose GraphQL/APOLLO -无法在类型“Query”上查询字段“field_name”

k75qkfdt  于 2024-01-08  发布在  Go
关注(0)|答案(1)|浏览(180)

我试图在最新的apollo/server 4.9和graphqlClient - 3.7中进行这样的查询,如下所示:

  1. const USER_DATA = gql`
  2. query getUserData($subdomain: String!) {
  3. getUserData(subdomain: $subdomain) {
  4. _id
  5. full_name
  6. email
  7. valid_complex_password
  8. projects {
  9. _id
  10. image_url
  11. title
  12. description
  13. street_address
  14. city
  15. province
  16. country
  17. }
  18. }
  19. }

字符串
但不断得到这个:

  1. {
  2. "errors": [
  3. {
  4. "message": "Cannot query field \"getUserData\" on type \"Query\".",
  5. "locations": [
  6. {
  7. "line": 2,
  8. "column": 3
  9. }
  10. ],
  11. "extensions": {
  12. "code": "GRAPHQL_VALIDATION_FAILED",
  13. "stacktrace": [
  14. "GraphQLError: Cannot query field \"getUserData\" on type \"Query\".",
  15. ......
  16. ]
  17. }
  18. }
  19. ]


}

同样的查询在旧版本的apollo server/client和graphql上运行良好。升级后,它开始崩溃,而没有对schema等进行任何更改。

有什么需要改变的方式,这是查询或我错过了什么?
迁移

  1. "apollo-server-errors": "^3.3.1",
  2. "apollo-server-express": "^2.16.1",
  3. "apollo-upload-server": "^7.1.0",
  4. "graphql": "^14.6.0",
  5. "graphql-compose": "^7.17.0",
  6. "graphql-compose-aws": "^4.0.1",
  7. "graphql-compose-connection": "^6.2.0",
  8. "graphql-compose-mongoose": "^7.3.8",
  9. "graphql-middleware": "^4.0.2",
  10. "graphql-redis-subscriptions": "^2.2.2",
  11. "graphql-tools": "^4.0.8",


  1. "@apollo/server": "^4.9.5",
  2. "graphql": "^16.8.1",
  3. "graphql-compose": "^9.0.10",
  4. "graphql-compose-aws": "^5.3.0",
  5. "graphql-compose-connection": "^8.2.1",
  6. "graphql-compose-mongoose": "^10.0.0",
  7. "graphql-middleware": "^6.1.35",
  8. "graphql-redis-subscriptions": "^2.6.0",
  9. "graphql-subscriptions": "^2.0.0",

rsaldnfx

rsaldnfx1#

简短的回答是,你已经在Apollo-server中迁移了两个版本的破坏性更改。你需要migrate你的项目才能让它在apollo-server v4.x世界中工作。
如果你不使用express来提供任何其他内容,我建议你使用apollo-server而不用express。

相关问题