graphql-fields icon indicating copy to clipboard operation
graphql-fields copied to clipboard

Doesn't acknowledge default argument values

Open dan-kwiat opened this issue 5 years ago • 3 comments

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 avatar Feb 26 '19 15:02 dan-kwiat

@dan-kwiat Did you find a workaround for this at all?

OliverCole avatar Sep 23 '19 14:09 OliverCole

@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

dan-kwiat avatar Sep 26 '19 15:09 dan-kwiat

I've also found graphql-parse-resolve-info, which does include the default values.

OliverCole avatar Apr 11 '20 16:04 OliverCole