In this example
"sellingPlansToCreate": [
{
"name": "Delivered every week",
"options": "1 Week(s)",
options is a string. however, the input expects an array. SellingPlanInput - GraphQL Admin
Anchor to SellingPlanInput.options
options: [String!]
The values of all options available on the selling plan. Selling plans are grouped together in Liquid when they're created by the same app, and have the same selling_plan_group.name and selling_plan_group.options values.
The property description doesn’t really explain. Furthermore, it isn’t clear how this options
could ever be plural. Ex: if you wanted to have 3weeks, 4weeks, those would need to be separate sellingPlans.
Also, when compared to the other example ( Build a selling plan ), it is even more confusing:
- Its
sellingPlanInput.options
shows a string even though graphql expects an array
- Its
sellingPlanGroupInput.options
also shows an array, but the example suggests a string would be better (even though that would also violate the spec). The Graphql description says this is The values of all options available on the selling plan group.
However, instead it looks like it is a description of the sellingplan options (ex: the label for a select element)
I can find no example of how/why shopify expects an array for these options properties.
I tested the “Build a selling plan” example:
- exactly as shown: it does work even though the graphql spec says the options must be a string.
- If I then change the
SellingPlanGroupInput.option
to an array with the same single element, it works the same.
- If I then add a second element to
SellingPlanGroupInput.option
, it errors: "Option2 Option2 is required as there is an option2 label defined on the parent selling plan group."
on each example
- If I then convert the
SellingPlanInput.option
for each to a 2-element array, it works again.
- If I then remove an element so the
SellingPlanGroupInput.option
is a single element but the sellingPlans have two elements, it errors Option2 Cannot define option2 on this selling plan as there is no label on the parent selling plan group.
So, based on the graphql responses:
- the
SellingPlanGroupInput.option
is not a list of all options as stated in the docs. it is a DESCRIPTION of the selling plan options.
- The examples and graphql accept a union
String! | [String!]
despite the docs which state only an array is allowed.