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

Uniqueness of field aliases

Open wutsch0 opened this issue 1 year ago • 3 comments

Both the latest released spec and the working draft don't contain any information on field alias uniqueness requirements. Field aliases need to be unique at least within the same object by common sense, but it is not specified if they need to be unique globally within the whole request or can be reused in different objects.

Deciding for the one or the other could be a breaking change for existing implementations.

To my understanding of the Contribution guidelines, deciding on that topic requires to follow the RFC process, which requires a champion to pick up this topic :pray:

wutsch0 avatar Nov 21 '24 18:11 wutsch0

My very superficial/immediate thoughts on this is that the field merging validation takes care of this. It's okay to have the same alias multiple times as long as fields can merge:

{
  foo: user {
    name
  }
  # this is OK
  foo: user {
    email
  }
}

It should also be fine to use the same alias in different objects. Or is there somewhere where this is problematic?

martinbonnin avatar Nov 21 '24 18:11 martinbonnin

I still need to read in detail through the field merging specification, but I did understand that this actually tells about uniqueness requirements. As this is not easy to parse an not obvious where to find, I think adding a paragraph to 2.7 Field Alias section would be helpful.

To my understanding this addition wouldn't require the RFC process, as its not changing the spec but improving legibility. I'll try to come up with a PR soon

wutsch0 avatar Dec 04 '24 08:12 wutsch0

This would indeed be an editorial change. We look forward to your PR @wutsch0 :raised_hands:

benjie avatar Dec 04 '24 10:12 benjie