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

There is no support for aliased fields

Open gienec opened this issue 5 years ago • 5 comments

Request example:

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

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

gienec avatar Dec 13 '18 15:12 gienec

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

dhurlburtusa avatar Mar 01 '19 20:03 dhurlburtusa

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

rtercias avatar Mar 01 '19 21:03 rtercias

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

robrichard avatar Mar 04 '19 17:03 robrichard

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

gienec avatar Jul 25 '19 17:07 gienec

@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

robrichard avatar Aug 02 '19 18:08 robrichard