graphql / graphql/graphql-spec

[FEATURE-REQUEST] Select depth operator *>[number]

Open
#971 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Been suggested before but I'm adding another spin on it. Lot of people requesting and a lot of up-votes for, I see answers as to why it's not being implemented but they are not valid responses; there's simply no excuse for not having this key functionality;

It is possible to do this with an pre-query and by hacking together the fields; but it's not consistent or reliable and you have to make a request queue & two requests which isn't a great dev experience. Should be handled by the spec server-side.

I'm managing a few projects with many different languages and remote crash logs. (TypeScript, Rust, Dart)
Our number one crash right now is missing fields in JSON -> class mapping, across projects. That's our number 1 crash and it's caused because of GraphQL.

We have to build most of our models like this, being careful not to miss fields when adding/updating

```
final roomResultFields = r'''
company {
{companyFields}
}
room {
{roomFields}
}
totalMembers
isMemberOfCompany
isInRoom
roomMembers {
memberDetails {
{roomMemberFields}
}
userLight {
{userLightFields}
}
}
'''
.replaceFirst("{companyFields}", companyFields)
.replaceFirst("{roomFields}", roomFields)
.replaceFirst("{roomMemberFields}", roomMemberFields)
.replaceFirst("{userLightFields}", userLightFields);
```

^^ Every model has this. It sucks. Across the GraphQA projects I've seen and manage it's always the same story, this sucky query module duplication.

We really like GraphQL but our major issue is that the select all field is missing. Instead I propose a select depth field.

The community wants it.

![IMG_1409](https://user-images.githubusercontent.com/6940726/179174726-944b0b2d-5662-42ce-8bc3-12159c316f15.PNG)

![IMG_1408](https://user-images.githubusercontent.com/6940726/179174776-2b32b43b-ca07-4553-8ce7-0b81df5b863e.PNG)

Instead of select *, why not select depth. For example *>1 could get level 1 fields, *>* could "get all", etc you get the point.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.