dsadasd12132 2018-05-06 21:28
浏览 194

Graphql查询在Apollo Client和graphql-go中出现'Unknown type Int'错误

I've got a graphql server implemented with graphql-go, and I'm using Apollo on the front end. Simple queries without arguments, and mutations using input object types work fine, but for some reason passing a scalar type argument in a query returns the error:

[{"message":"Unknown type \"Int\".","locations":[{"line":1,"column":19}]}]

My use could not be simpler; on the client side, my query is:

export const GET_CLIENT = gql`
  query client($id: Int) {
  client(id: $id) {
    id
    name
  }
}`

which is used in a component like so:

<Query
  query={GET_CLIENT}
  variables={{
    id: 1
  }} />

which resolves to this field on the backend:

// ClientQuery takes an ID and returns one client or nil
var ClientQuery = &graphql.Field{
Type: ClientType,
Args: graphql.FieldConfigArgument{
    "id": &graphql.ArgumentConfig{
        Type: graphql.Int,
    },
},
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
    return p.Context.Value("service").(*model.Service).FindClientByID(id)
},
}

I've tried passing input objects, strings, etc. but it seems that no query arguments, scalar or otherwise are ever satisfied on the backend. I've tried both master and v0.7.5 of graphql-go. Am I missing something? Help very much appreciated, it feels weird for something this basic to be such a huge blocker.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!