graphql-go / graphql-go/graphql
some object properties are empty strings instead of actual values
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
Hello.
I use Macbook Pro with MacOS Mojave 10.14.1 Beta with go 1.11.1 and angular 7rc with angular-apollo.
(this problem does not related to angular at all, it happens with angular6 stable as well)
I created a new input object that contains the following parameters:
deliveryId as int,
payment as a payment input object I configured
products as a new list of product input object i configured
and address as an address input object I configured.
it seems that whenever I add input object fields that are my own types, they always return empty values unless I define them as a list and send them as an array.
this is how I define my types:
```
cartProduct := graphql.NewInputObject(
graphql.InputObjectConfig{
Name: "CartProduct",
Fields: graphql.InputObjectConfigFieldMap{
"id": &graphql.InputObjectFieldConfig{
Type: graphql.Int,
},
"quantity": &graphql.InputObjectFieldConfig{
Type: graphql.Int,
},
},
},
)
deliveryAddress := graphql.NewInputObject(
graphql.InputObjectConfig{
Name: "DeliveryAddress",
Fields: graphql.InputObjectConfigFieldMap{
"name": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"address": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"city": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
},
},
)
payment := graphql.NewInputObject(
graphql.InputObjectConfig{
Name: "CreditCardPayment",
Fields: graphql.InputObjectConfigFieldMap{
"name": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"number": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"expiry": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
"cvc": &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
},
},
)
order := graphql.NewInputObject(
graphql.InputObjectConfig{
Name: "Order",
Fields: graphql.InputObjectConfigFieldMap{
"deliveryId": &graphql.InputObjectFieldConfig{
Type: graphql.Int,
},
"payment": &graphql.InputObjectFieldConfig{
Type: payment,
},
"products": &graphql.InputObjectFieldConfig{
Type: cartProduct,
},
"address": &graphql.InputObjectFieldConfig{
Type: deliveryAddress,
},
},
},
)
```
this is how I configured the addOrderInfo mutation:
```
"addOrderInfo": &graphql.Field{
Type: ContactUsType,
Args: graphql.FieldConfigArgument{
"order": &graphql.ArgumentConfig{
Type: order,
},
"shop_id": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.Int),
},
},
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
## HERE i stop with a breakpoint to see the data the params provide
},
},
```
I execute the mutation with angular-apollo with the following code:
```
addOrderInfo(order) {
const shopId = this.env.shopId;
return this.apollo.mutate({
mutation: gql`
mutation AddOrderInfo($order: Order!
$shopId: Int!
) {
addOrderInfo(order: $order, shop_id: $shopId) {
id
}
}`,
variables: {order,shopId}
});
}
```
the working scenario:
I needed to modify that address and payment params will be lists instead:
```
order := graphql.NewInputObject(
graphql.InputObjectConfig{
Name: "Order",
Fields: graphql.InputObjectConfigFieldMap{
"deliveryId": &graphql.InputObjectFieldConfig{
Type: graphql.Int,
},
"payment": &graphql.InputObjectFieldConfig{
Type: graphql.NewList(payment),
},
"products": &graphql.InputObjectFieldConfig{
Type: graphql.NewList(cartProduct),
},
"address": &graphql.InputObjectFieldConfig{
Type: graphql.NewList(deliveryAddress),
},
},
},
)
```
and of course when I created the orderInfo object that I'm sending, I created an array for address and payment that contains the object instead of the actual object,
and here the data is received in go properly.
is there something that I'm missing or is it a bug ?
Contributor guide
Assessment
This issue has not been assessed yet.