I want to pass dynamic variables of type Enum from a scenario step to a graphql mutation. My current implementation:
Scenario: Update device settings
...
* def wifi = ON
* def bluetooth = OFF
* def query = read('update-device-settings.graphql')
* def variables = { wifi: #(wifi), bluetooth: #(bluetooth) }
When request { query: #(query), variables: #(variables) }
When method POST
...
mutation ($wifi: __EnumValue!, $bluetooth: __EnumValue!) {
updateDeviceSettings(
input: {
wifi: $wifi,
bluetooth: $bluetooth,
}
)
}
But I already get this error in the scenario:
* def wifi = ON
>>>> js failed:
01: ON
<<<<
org.graalvm.polyglot.PolyglotException: ReferenceError: "ON" is not defined
- <js>.:program(Unnamed:1)
How can I create an pass enum values? Or could I pass string values (e.g. 'ON') and get it parsed in the Graphql file?
EDIT: These values for wifi
and bluetooth
are not strings. This is the working cURL request:
curl \
--header "Content-Type: application/json" \
--request POST \
--data '{ "query": "mutation { updateDeviceSettings( input: { wifi: ON, bluetooth: OFF } ) }" }' https://ip:port/path