Problem with fulfillmentCreate

Hi, I’m trying to create a fulfillment using GraphQL, using this page as a reference: fulfillmentCreate - GraphQL Admin

Until now I’ve been pretty successful converting to GraphQL just by following the examples. But not with this one. Here is the data I’m sending to Shopify:

{
    "query": "mutation fulfillmentCreate($fulfillment: FulfillmentInput!) {  fulfillmentCreate(fulfillment: $fulfillment) { fulfillment { notifyCustomer trackingInfo { number url company } lineItemsByFulfillmentOrder { fulfillmentOrderId fulfillmentOrderLineItems { id quantity }}  } userErrors {field message}}}",
    "variables": {
        "fulfillment": {
            "notifyCustomer": true,
            "trackingInfo": {
                "company": "USPS",
                "url": "https://tools.usps.com/go/TrackConfirmAction.action?tRef=fullpage&tLc=1&text28777=&tLabels=9434611206224830964813",
                "number": "9434611206224830964813"
            },
            "lineItemsByFulfillmentOrder": [
                {
                    "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/7463001751613",
                    "fulfillmentOrderLineItems": [
                        {
                            "id": "gid://shopify/FulfillmentOrderLineItem/15046805979197",
                            "quantity": 1
                        },
                        {
                            "id": "gid://shopify/FulfillmentOrderLineItem/15046806011965",
                            "quantity": 1
                        }
                    ]
                }
            ]
        }
    }
}

When I do, I get an error that says “Field ‘notifyCustomer’ doesn’t exist on type ‘Fulfillment’”. Well, that message doesn’t help, as it most certainly does, at least according to the page I mentioned at the beginning.

Am I formatting this wrong? It would help if that page included a variety of good examples like so much of the rest of the GraphQL docs.

Any information or help figuring this out would be much appreciated.

Thanks!

Hey, your variables look fine for the mutation, the error is from your mutation results/returns.
In your query you are asking for the field notifyCustomer on the fulfillment return which doesn’t exist fulfillmentCreate - GraphQL Admin

Thanks for the reply. I’m having a hard time understanding the structure of mutations, which is why I’m not understanding what goes where. Mostly, I’ve made this work using the CURL examples throughout the documentation.

Can you tell me how my mutation should look? The only thing I really need returned is the fulfillment id and the userErrors.

I figured it out. And I now understand the mutation just a little better (although not completely) I used:

mutation  fulfillmentCreate($fulfillment: FulfillmentInput!) {  fulfillmentCreate(fulfillment: $fulfillment) { fulfillment { id } userErrors {field message}  }}

I don’t fully understand the “variables” ($fulfillment) in the query and the results or why they are even there. But it works and that’s all that matters.

1 Like

The variables are the inputs to your mutation.
The results are there for you to check for errors and/or use the resulting data, after the mutation is made in some way.

Think of it in database terms, you’re doing a insert which you provide variables for. The insert statement runs with those.
Any errors are returned.
In database world you’d then query the data if you wanted to, but in graphql you can do that all in one go.