Describe the bug
ValuesResolver.getArgumentValues throws a NonNullableValueCoercedAsNullException even when
This behavior was introduced in GraphQL 17 or 18 in #2308. Before that, getArgumentValues would return null if no parameter was present.
To Reproduce
Example toy schema based on my own schema:
type Query {
friends(userId: ID!): FriendConnection
}
type FriendConnection {
edges: [FriendEdge]
aggregatedStats(input: StatsInput!): Stats!
}
type FriendEdge {
cursor: String!
node: Friend
}
type Friend {
name: String!
stats(input: StatsInput!): Stats!
}
input StatsInput {
fields: [String!]!
}
We use getArgumentValues in our FriendsDataFetcher (which handles Query.friends) to check if we are fetching Friend.stats so we can pre-load the stats and improve performance. Upgrading to GraphQL-Java 18 caused a regression on this data fetcher in the case where we don't ask for the field at all.
var valuesResolver = new ValuesResolver();
GraphQLSchema schema = dataFetchingEnvironment.getGraphQLSchema();
var parentType = (GraphQLObjectType) schema.getType(parentFieldName);
GraphQLFieldDefinition fieldDef = Introspection.getFieldDef(schema, parentType, fieldName);
This is a simplified version of the query that triggers the issue. Because we don't ask for Friend.stats, if I want to check getArgumentValues for "stats" it will throw that NonNullableValueCoercedAsNullException.
query FriendAggregatedStatsQuery($userId: ID!, statsInput: StatsInput!) {
friends(userId: $userId) {
... on FriendConnection {
aggregatedStats {
value
}
}
}
}
Here is a query that will succeed on getArgumentValues:
query FriendStatsQuery($userId: ID!, statsInput: StatsInput!) {
friends(userId: $userId) {
... on FriendConnection {
edges {
node {
friend {
stats(input: $statsInput) {
value
}
}
}
}
}
}
}
Is it possible to return getArgumentValues to its previous behavior, or make an alternative that works with my use case?
Describe the bug
ValuesResolver.getArgumentValues throws a NonNullableValueCoercedAsNullException even when
This behavior was introduced in GraphQL 17 or 18 in #2308. Before that, getArgumentValues would return
nullif no parameter was present.To Reproduce
Example toy schema based on my own schema:
We use
getArgumentValuesin ourFriendsDataFetcher(which handles Query.friends) to check if we are fetching Friend.stats so we can pre-load the stats and improve performance. Upgrading to GraphQL-Java 18 caused a regression on this data fetcher in the case where we don't ask for the field at all.This is a simplified version of the query that triggers the issue. Because we don't ask for Friend.stats, if I want to check
getArgumentValuesfor "stats" it will throw that NonNullableValueCoercedAsNullException.Here is a query that will succeed on
getArgumentValues:Is it possible to return
getArgumentValuesto its previous behavior, or make an alternative that works with my use case?