in my golang project I use https://github.com/shurcooL/graphql for graphql queries and I need to make the following mutation:
mutation createPromotion($input: CreatePromotionInput) {
createPromotion(input: $input)
}
with the following graphql variables:
{
"input": {
"channel": "my_channel",
"offerType": "my_offer_type",
}
}
In my code it looks like this:
type CreatePromotion struct {
CreatePromotion graphql.String
}
func (g *Gate) CreatePromotion(ctx context.Context) (*CreatePromotion, error) {
var mutation struct {
CreatePromotion CreatePromotion `graphql:"createPromotion(input: {channel: $channel,
offerType: $offerType})"`
}
variables := map[string]interface{}{
"channel": graphql.String("my_channel"),
"offerType": graphql.String("my_offer_type"),//error is here
}
err := g.graphqlClient.Mutate(ctx, &mutation, variables)
if err != nil {
return nil, err
}
return &mutation.CreatePromotion, nil
}
But when I execute my query I get the following error: Variable "$offerType" of type "String!" used in position expecting type "OfferType!"
. Unfortunately I neither have idea what type OfferType!
is, nor how am I expected to make it.
Any ideas how to fix it would be welcome. Thank you.