I’m using the <validate-graphql-request />
Azure API Management policy.
Here is a sample schema:
type Query {
hello(world: String!): String!
greetings(world: Greetings): String!
}
input Greetings {
hello: String!
}
Through API Management, you can test the API by manually writing text into the Query editor and, optionally some Query variables.
Both the hello
and greetings
query work when specifying static hardcoded arguments in the Query editor. However, only the hello
query works when using variables as it expects a SCALAR value. Unfortunately, specifying an object variable for the input argument to the greetings
query does not work and raise the following error:
Unable to parse input as a 'Greetings' type. Did you provide a List or Scalar accidentally?
It appears that this error is actually raised by the GraphQL.Net library which might be used internally by Azure API Management. This NuGet has a well-known fix for this error but it appears APIM is not using this fix in its parsing code.
For the record, here are the status of the various queries:
query |
variables |
status |
query{hello(world: "world!")} |
N/A |
✔ |
query($world: String!){hello(world: $world)} |
{"world": "world!"} |
✔ |
query{greetings(world: { hello: "world!" })} |
N/A |
✔ |
query($world: Greetings){greetings(world: $world)} |
{"world":{"hello": "world!"}} |
❌ `"Variable '$world' is invalid. Unable to parse input as a 'Greetings' type. Did you provide a List or Scalar value accidentally? "' |
Is there anything I’m missing?