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

k75qkfdt  于 12个月前  发布在  Go
关注(0)|答案(1)|浏览(119)

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

const USER_DATA = gql`
query getUserData($subdomain: String!) {
getUserData(subdomain: $subdomain) {
  _id
  full_name
  email
  valid_complex_password
  projects {
    _id
    image_url
    title
    description
    street_address
    city
    province
    country
  }
 }
}

字符串
但不断得到这个:

{
"errors": [
    {
        "message": "Cannot query field \"getUserData\" on type \"Query\".",
        "locations": [
            {
                "line": 2,
                "column": 3
            }
        ],
        "extensions": {
            "code": "GRAPHQL_VALIDATION_FAILED",
            "stacktrace": [
                "GraphQLError: Cannot query field \"getUserData\" on type \"Query\".",
                ......
            ]
        }
    }
]


}

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

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

"apollo-server-errors": "^3.3.1",
"apollo-server-express": "^2.16.1",
"apollo-upload-server": "^7.1.0",
"graphql": "^14.6.0",
"graphql-compose": "^7.17.0",
"graphql-compose-aws": "^4.0.1",
"graphql-compose-connection": "^6.2.0",
"graphql-compose-mongoose": "^7.3.8",
"graphql-middleware": "^4.0.2",
"graphql-redis-subscriptions": "^2.2.2",
"graphql-tools": "^4.0.8",


"@apollo/server": "^4.9.5",
"graphql": "^16.8.1",
"graphql-compose": "^9.0.10",
"graphql-compose-aws": "^5.3.0",
"graphql-compose-connection": "^8.2.1",
"graphql-compose-mongoose": "^10.0.0",
"graphql-middleware": "^6.1.35",
"graphql-redis-subscriptions": "^2.6.0",
"graphql-subscriptions": "^2.0.0",

rsaldnfx

rsaldnfx1#

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

相关问题