-
Notifications
You must be signed in to change notification settings - Fork 63
Non nullable enums are not always discoverable in mutations #433
Description
I've added [GraphQLInputType] input type for a mutation with the following Enums:
public Test Test1 { get; init; }
public Test? Test2 { get; init; }
public required Test Test3 { get; init; }
public required Test? Test4 { get; init; }
[Required]
public required Test Test5 { get; init; }
[Required]
public required Test? Test6 { get; init; }It seems that both in Postman and in Strawberry Shake, only test2, test4, and test6, are discoverable via GraphQL introspection, while test1, test3, and test5 aren't.
Reproduction is available in the following gist, or here: EntityGraphQL_EnumNotDiscoverable.zip
Note that in [GraphQLArguments] input type it doesn't happen.
Used version: EntityGraphQL.AspNet 5.5.0 (although in 5.5.2 it's the same, but the reproduction above is with 5.5.0).
Details:
When running the code above and executing HTTP GET on http://localhost:5144/schema, i.e.
curl -X 'GET' \
'http://localhost:5144/schema' \
-H 'accept: text/plain'We get:
schema {
query: Query
mutation: Mutation
}
"""Boolean scalar"""
scalar Boolean
"""Char scalar"""
scalar Char
"""Date with time scalar"""
scalar Date
"""Date value only scalar"""
scalar DateOnly
"""DateTimeOffset scalar"""
scalar DateTimeOffset
"""Float scalar"""
scalar Float
"""ID scalar"""
scalar ID
"""Int scalar"""
scalar Int
"""String scalar"""
scalar String
"""Time value only scalar"""
scalar TimeOnly
"""Directs the executor to include this field or fragment only when the `if` argument is true."""
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"""Directs the executor to skip this field or fragment when the `if` argument is true."""
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
enum Test {
TestA
TestB
}
type Query {
people: [Person!]!
}
type Person {
age: Int!
name: String!
}
input PersonMutationArgs {
age: Int!
personName: String!
test1: Test!
test2: Test
test3: Test!
test4: Test
test5: Test!
test6: Test!
}
type Mutation {
"""Add a new person to the system"""
addNewPerson(args: PersonMutationArgs!): Person!
"""Add a new person to the system"""
addNewPersonFlat(personName: String!, age: Int!, test1: Test!, test2: Test, test3: Test!, test4: Test, test5: Test!, test6: Test!): Person!
}
I'm not entirely sure that test5 and test6 are correct.
In the code, I have:
[Required]
public required Test Test5 { get; init; }
[Required]
public required Test? Test6 { get; init; }While in the response I have:
test5: Test!
test6: Test!
and: test5: Test!, test6: Test!.
But that's not the issue (but is it an issue?)
When I perform introspection, e.g. running:
curl -X POST \
http://localhost:5144/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name } } } }"
}'
I get: introspection_response.json
In it, I can see that test2 appears three times, with "kind": "INPUT_OBJECT" on two occasions, and test3 appears only two times, with "kind": "NON_NULL", in both instances. Something is off here, and as mentioned before, both Postman and Strawberry Shake don't see them at all.
Also note that while these aren't discoverable with [GraphQLInputType], they actually do work, and I'm able to execute mutations and use them, just not discover them.
Thanks in advance!