graphql-go / graphql-go/graphql

params.Args of the nested element is empty

Open
#444 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
10.1k
Forks
845
PR merge metrics
No merged PRs in 30d

Description

What am I trying to do:

var mutationKittensType = graphql.NewObject(
graphql.ObjectConfig{
Name: "kittens",
Fields: graphql.Fields{
"littleName": &graphql.Field{
Type: graphql.String,
},
"age": &graphql.Field{
Type: graphql.Float,
},
},
},
)

var mutationPropertiesType = graphql.NewObject(
graphql.ObjectConfig{
Name: "properties",
Fields: graphql.Fields{
"name": &graphql.Field{
Type: graphql.String,
},
"kittens": &graphql.Field{

Type: mutationKittensType,
},
},
},
)

var mutationType = graphql.NewObject(
graphql.ObjectConfig{
Name: "create_cat",
Fields: graphql.Fields{
"type": &graphql.Field{
Type: graphql.String,
},
"properties": &graphql.Field{
Type: mutationPropertiesType,
},
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
log.Println("params.Args ", params.Args)`

For example, this curl:

` curl -XPOST http://localhost/graphql -H 'Content-Type: application/graphql' -d'mutation{create_cat(type:"persian", properties:{name: "alice", kittens:{littleName: "little alice", age: 1}}){type, properties{name, kittens:{littleName, age}}}}'`

I got this:
> params.Args map[ ]

Why is my params.Args empty and how to fix it?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.