graphql-fields
graphql-fields copied to clipboard
Doesn't acknowledge default argument values
Issue
Default argument values defined in GraphQL Schema Language are not respected (when using the processArguments option).
Example
Schema:
type Bucket {
id: ID,
count: Int,
}
type Aggregations {
income: [Bucket]
geo(
top: Float = 90,
left: Float = -180,
bottom: Float = -90,
right: Float = 180
): [Bucket]
}
type Query {
aggregate: Aggregations
}
Query:
{
aggregate {
geo {
id
count
}
}
}
Resolver:
const aggregate = (args, _, info) => {
const requestedFields = graphqlFields(info, {}, { processArguments: true })
// requestedFields.geo.__arguments is undefined
...
}
@dan-kwiat Did you find a workaround for this at all?
@OliverCole No but I found a different approach to dealing with the requested fields (not using this package). Inspired by this comment: https://github.com/graphql/graphql-js/issues/19#issuecomment-119348258
I've also found graphql-parse-resolve-info, which does include the default values.