GraphQL scriptTagDelete mutation wrong ID

Solved
New Member
3 0 0

I'm trying to delete a scripttag using GraphQL mutation. 

 

This is the request body from the Network tab.

{"operationName":"scriptTagDelete",
"variables":{"input":{"id":"gid://shopify/ScriptTag/33627209833"}},
"query":"mutation scriptTagDelete($id: ID!) {\n scriptTagDelete(id: $id) {\n deletedScriptTagId\n userErrors {\n field\n message\n __typename\n }\n __typename\n }\n}\n"}

This is error message:

{"errors":[{"message":"Variable id of type ID! was provided invalid value","locations":[{"line":1,"column":26}],"extensions":{"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}}]}
0 Likes

Success.

Shopify Partner
1843 170 534

Why is variables wrapped in input?

"variables":{"input":{"id":"gid://shopify/ScriptTag/33627209833"}}

You're not defining a variable named input so it should only be 

"variables":{"id":"gid://shopify/ScriptTag/33627209833"}

 

I turn coffee in to code - since 1998
1 Like
New Member
3 0 0

@KarlOffenberger wrote:

Why is variables wrapped in input?

"variables":{"input":{"id":"gid://shopify/ScriptTag/33627209833"}}

You're not defining a variable named input so it should only be 

"variables":{"id":"gid://shopify/ScriptTag/33627209833"}

 


Thanks Karl,

I didn't notice that difference. I thought it was the standard of the graphql.

0 Likes
Highlighted
Shopify Partner
1843 170 534

No problem. GraphQL is quite beautiful to work with once you get the hang of it. If anything else pops up, feel free to ask here but GraphQL questions are also well served over on StackOverflow as it doesn't only apply to Shopify.

I turn coffee in to code - since 1998
0 Likes