graphql-go / graphql-go/graphql

could not resolved all fields in input argument in ResolveParams.Args

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

Description

When I request a mutation to my graphql server(using graphql-go) but i didn't get all the fields of the argument cart.

```
mutation($user_id: Int, $session_id: String, $product_id: Int!, $quantity: Int!, $cart: CartInput) {
add_to_cart(user_id: $user_id, session_id: $session_id, product_id: $product_id, quantity: $quantity, cart: $cart) {

... some fields ...

}
}
```

But graphql resolve 3 fields of the 12 fields.

```
func addToCart(params graphql.ResolveParams) (interface{}, error) {
u_id, uOk := params.Args["user_id"].(int)
s_id, _ := params.Args["session_id"].(string)
p_id, _ := params.Args["product_id"].(int)
quant, _ := params.Args["quantity"].(int)
cartarg, cartOk := params.Args["cart"].(model.Cart)
//cartOk - false !

fmt.Println("cart Args:", params.Args["cart"])

// -> cart Args:map[extra_large_cart:false items:[] not_selected:[]]
}
```

CartInput
```
var CartInputType = graphql.NewInputObject(graphql.InputObjectConfig{
Name: "CartInput",
Fields: graphql.InputObjectConfigFieldMap{
"promo": &graphql.InputObjectFieldConfig{
Type: CartPromoType,
},
"extra_large_cart": &graphql.InputObjectFieldConfig{
Type: graphql.Boolean,
},
"items": &graphql.InputObjectFieldConfig{
Type: graphql.NewList(ProductType),
},
"not_selected": &graphql.InputObjectFieldConfig{
Type: graphql.NewList(ProductType),
},
"delivery_data": &graphql.InputObjectFieldConfig{
Type: CartServiceType,
},
"bonuses": &graphql.InputObjectFieldConfig{
Type: graphql.Float,
},
"date": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"name": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"surname": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"patronymic": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"phone": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"email": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
},
},
)
```

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.