robrichard / graphql-fields

Turns GraphQLResolveInfo into a map of the requested fields
MIT License
350 stars 30 forks source link

There is no support for aliased fields #18

Open gienec opened 5 years ago

gienec commented 5 years ago

Request example:

{
  field {
     subField(arg: 1)
     a:subField(arg: 2)
  }
}

This will return only second field subField with argument which value is 2.

dhurlburtusa commented 5 years ago

@gienec I too need support for aliases. Do you have a suggestion for a backwards compatible way to support aliases?

rtercias commented 5 years ago

A while ago, I made an attempt to use aliases in this library, but decided to go a different route for my particular use case. Perhaps one way to solve this is by adding a second exported function called graphQLAliases, which would call an internal function similar to getAST, but return the aliases instead of the field names.

See this abandoned PR for some ideas: https://github.com/robrichard/graphql-fields/pull/8/files

robrichard commented 5 years ago

See https://github.com/robrichard/graphql-fields/issues/27

gienec commented 5 years ago

@robrichard, could you review this PR #31 ? It does what I need.

robrichard commented 5 years ago

@gienec, I don't plan on adding support for aliases as it cannot be cleanly supported with the current API. I'm working on a replacement library with a new API that will correctly support arguments and directives. See the discussion here: https://github.com/robrichard/graphql-fields/issues/27