Getting error "Nullability Mismatch on variable $fulfillment....." when invoking a graphQL mutation

Ashfaq_
Shopify Partner
4 0 4

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

 
 

image (1).pngimage (2).pngimage (3).pngimage (4).png

 

Reply 1 (1)

Ole_
Shopify Partner
41 8 19

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
    }
  }
}`;
If you find my suggestions helpful, kindly express your feedback by liking or marking them as a solution.

visionz.de