A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Nullability Mismatch on variable $fulfillment and argument fulfillment (FulfillmentV2Input/FulfillmentV2Input!)
After failing to call the fulfillment API using Rest, I went ahead with integrating the same thing using GraphQL but I am unable to understand why I am encountering this error.
Documentation for reference: https://shopify.dev/api/admin-graphql/2022-01/mutations/fulfillmentCreateV2
For future readers...
The error is telling us that you gave an argument of type FulfillmentV2Input but fulfillmentCreateV2(fulfillment) needs an argument of type FulfillmentV2Input! (aka a FulfillmentV2Input that can't be null).
So the code that will solve this error looks like this:
const mutation = `mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {
fulfillmentCreateV2(fulfillment: $fulfillment) {
fulfillment {
trackingInfo {
url
number
company
}
}
userErrors {
field
message
}
}
}`;