【问题标题】:Apollo: Unknown type 'contact_id', did you mean 'contactType' or 'Contact'Apollo:未知类型“contact_id”,您的意思是“contactType”还是“Contact”
【发布时间】:2020-03-20 13:59:12
【问题描述】:

我使用"apollo-server": "^2.9.11" 并具有以下架构以分段上传文件

type Mutation {
    ...
    updateProfileImage(contact_id: ID!, file: Upload!): String!
}

当我使用graphql_flutter 2.1.0 客户端查询它时,我收到以下错误:

Unknown type 'contact_id', did you mean 'ContactType' or 'Contact'

虽然在我添加 contact_id 参数(我需要在解析器中)之前它正在使用 file 参数(流和上传文件)。

使用 Apollo 上传文件时是否有任何限制,例如不添加其他参数?还是有其他原因?

更新:查询

在颤振方面,我是这样发送的:

r”“”
   mutation($contactId : contact_id , $file: Upload!){
     uploadProfileImage(contact_id: $contactId ,file: $file)
   }
“”"

虽然查询是这样的(文件正在上传):

r”“”
   mutation($file: Upload!){
     uploadProfileImage(file: $file)
   }
“”"

但是在将 contact_id 参数添加到我的架构和查询后,我开始收到该错误。

【问题讨论】:

  • 听起来您的查询格式不正确。请更新您的问题以包含实际发送查询的代码。
  • @DanielRearden 已更新。
  • 那么...为什么$contactId 变量的类型是contact_id?据推测,如错误所示,您没有具有该名称的类型。
  • 是的,我发布后才发现,谢谢 :)

标签: flutter graphql apollo apollo-server


【解决方案1】:

所以我只是在查询中将$contactId 变量类型更改为ID! 并且它起作用了。

r”“”
   mutation($contactId : ID! , $file: Upload!){
     uploadProfileImage(contact_id: $contactId ,file: $file)
   }
“”"

【讨论】:

    猜你喜欢
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    相关资源
    最近更新 更多