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

[RFC] @skip/include directive: ability to define default/fallback value #475

Open
slorber opened this issue Jun 27, 2018 · 2 comments
Open
Labels
👻 Needs Champion RFC Needs a champion to progress (See CONTRIBUTING.md) 💭 Strawman (RFC 0) RFC Stage 0 (See CONTRIBUTING.md)

Comments

@slorber
Copy link

slorber commented Jun 27, 2018

Let's say my app have a React component with an associated GraphQL fragment.

This fragment is used in 10 distinct queries. As of today, field x always has to be fetched, but a new business requirement ask to not fetch this field, just for one of the 10 queries.

I can add the following to my fragment:

x @skip(if: $skipX)

But now, I have to provide a $skipX variable for all of my 10 queries, which seem doable but annoying.

I've like to have a syntax like

x @skip(if: $skipX = false)

so that I only have to modify the variables of a single query

What do you think about this?

Is there any alternative to my need which does not require modifying all my existing queries?

@slorber
Copy link
Author

slorber commented Jun 27, 2018

As a sidenote, if parametrized fragments existing I could probably define a default value on the fragment itself: #204

@leebyron leebyron added 💭 Strawman (RFC 0) RFC Stage 0 (See CONTRIBUTING.md) 👻 Needs Champion RFC Needs a champion to progress (See CONTRIBUTING.md) labels Oct 2, 2018
@leebyron
Copy link
Collaborator

leebyron commented Oct 2, 2018

Callsite fallback values is interesting. I'm not sure it's definitely better than defining variables at the fragment boundary but there's certainly something valuable about it.

I'd love to see this more worked out to see if there are complications or challenges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👻 Needs Champion RFC Needs a champion to progress (See CONTRIBUTING.md) 💭 Strawman (RFC 0) RFC Stage 0 (See CONTRIBUTING.md)
Projects
None yet
Development

No branches or pull requests

2 participants