and run Absinthe.run(document, MyApp.Schema, variables: %{...}, operation_name: "Create"), which would in turn only execute the first mutation in the document.
Actual behavior
Instead, all mutations run regardless of which operation_name I provide, and I get errors for missing fields, etc., for mutations that I did not intend to run. I have done the following to troubleshoot:
Try using queries instead of mutations. This works, which leads me to believe Absinthe.run/3 does not currently support operation_name: for documents with mutations.
Pass an invalid operation_name. As expected, this throws an error saying Must provide a valid operation name if query contains multiple operations.
Ensure the mutation succeeds when I move each mutation into its own document, and run individually.
Below is the error I get when I attempt to run a test against a single mutation in the document:
code: assert {:ok, %{data: data}} = result
right: {:ok,
%{
errors: [
%{
locations: [%{column: 0, line: 42}],
message: "In argument \"modifier_choice\": Expected type \"DeleteModifierChoiceInput!\", found null."
},
%{
locations: [%{column: 0, line: 41}],
message: "Variable \"modifier_choice\": Expected non-null, found null."
},
%{
locations: [%{column: 0, line: 37}],
message: "In argument \"modifier_choice\": Expected type \"UpdateModifierChoiceInput!\", found null."
},
%{
locations: [%{column: 0, line: 36}],
message: "Variable \"modifier_choice\": Expected non-null, found null."
},
%{
locations: [%{column: 0, line: 32}],
message: "In argument \"modifier_choice\": Expected type \"CreateModifierChoiceInput!\", found null."
},
%{
locations: [%{column: 0, line: 31}],
message: "Variable \"modifier_choice\": Expected non-null, found null."
},
%{
locations: [%{column: 0, line: 27}],
message: "In argument \"modifier_group\": Expected type \"DeleteModifierGroupInput!\", found null."
},
%{
locations: [%{column: 0, line: 26}],
message: "Variable \"modifier_group\": Expected non-null, found null."
},
%{
locations: [%{column: 0, line: 22}],
message: "In argument \"modifier_group\": Expected type \"UpdateModifierGroupInput!\", found null."
},
%{
locations: [%{column: 0, line: 21}],
message: "Variable \"modifier_group\": Expected non-null, found null."
},
%{
locations: [%{column: 0, line: 17}],
message: "In argument \"modifier_group\": Expected type \"CreateModifierGroupInput!\", found null."
},
%{
locations: [%{column: 0, line: 16}],
message: "Variable \"modifier_group\": Expected non-null, found null."
},
%{
locations: [%{column: 0, line: 12}],
message: "Argument \"product\" has invalid value $product.\nIn field \"description\": Unknown field."
},
%{
locations: [%{column: 0, line: 2}],
message: "Argument \"product\" has invalid value $product.\nIn field \"name\": Expected type \"String!\", found null.\nIn field \"category\": Expected type \"String!\", found null.\nIn field \"catalogId\": Expected type \"ID!\", found null.\nIn field \"basePrice\": Expected type \"CurrencyInput!\", found null.\nIn field \"id\": Unknown field."
}
]
}}
It appears all the mutations that I did not intend to run are throwing errors, as I have not provide valid variables to them.
This is actually unrelated to mutations and more about variables. The variables of queries or mutations that are not current are still being checked for null. Fixed in the PR.
If submitting a bug, please provide the following:
Environment
Expected behavior
Based on the documentation for
Absinthe.run/3
, I would expect to be able to pass the following document:and run
Absinthe.run(document, MyApp.Schema, variables: %{...}, operation_name: "Create")
, which would in turn only execute the first mutation in the document.Actual behavior
Instead, all mutations run regardless of which
operation_name
I provide, and I get errors for missing fields, etc., for mutations that I did not intend to run. I have done the following to troubleshoot:Try using queries instead of mutations. This works, which leads me to believe
Absinthe.run/3
does not currently supportoperation_name:
for documents with mutations.Pass an invalid
operation_name
. As expected, this throws an error sayingMust provide a valid operation name if query contains multiple operations.
Ensure the mutation succeeds when I move each mutation into its own document, and run individually.
Below is the error I get when I attempt to run a test against a single mutation in the document:
It appears all the mutations that I did not intend to run are throwing errors, as I have not provide valid variables to them.
Relevant Schema/Middleware Code