Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't acknowledge default argument values #23

Open
dan-kwiat opened this issue Feb 26, 2019 · 3 comments
Open

Doesn't acknowledge default argument values #23

dan-kwiat opened this issue Feb 26, 2019 · 3 comments

Comments

@dan-kwiat
Copy link

dan-kwiat commented Feb 26, 2019

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
  ...
}
@OliverCole
Copy link

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

@dan-kwiat
Copy link
Author

@OliverCole No but I found a different approach to dealing with the requested fields (not using this package). Inspired by this comment: graphql/graphql-js#19 (comment)

@OliverCole
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants