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.
id
argument was actually named something else. Once I fixed my query so that other mistakes were gone, the error about Int was also gone – Matt Lavin