Happening now | Shopify Community AMA: User Research with CXL | Ask your questions now!
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

Ashfaq_
Shopify Partner
5 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_Visionz
Shopify Partner
53 10 22

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.
Our (German) agency: visionz.de
Our Shopify App for custom pricing & unlimited product options: Visionz Easy Product Options