GraphQL Admin API Orders Query NULL LineItem.Variant

We are querying GraphQL Admin API for orders using:

query OrderLineItems($id: ID!) {
	order(id: $id) {
		lineItems(first: 250) {
			nodes {
				id
				variant {
					id
				}
			}
		}
	}
}

We are dealing with multiple Shopify stores, and there is this certain store that gets “null” on the variant return, and we cannot figure out why. They have read_products and write_products scope. Please take note that the same query above works fine for other stores.

NULL Result:

{
	"data": {
		"order": {
			"lineItems": {
				"nodes": [
					{
						"id": "gid://shopify/LineItem/123456789",
						"variant": null
					},
					{
						"id": "gid://shopify/LineItem/999999999",
						"variant": null
					}
				]
			}
		}
	}
}

Is there any reason why is it returning null? They are on “Advanced” Shopify plan if that matters. Thank you.

+1 i’m seeing the same behavior for product and variant within lineItems

I have an update.

The store we are currently looking at is using a third-party app that creates a variant upon checkout and after that, the variant does not exist anymore. This might be why it is coming as NULL through the GraphQL Admin API. The strange thing is that this data is populated on the REST Admin API if we would query the same order.

1 Like