Skip to content

Commit cdf3677

Browse files
authored
Include potential implementation option in the RFC
1 parent 2009f8d commit cdf3677

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

rfcs/FragmentArguments.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ Additionally, the `@argumentDefinitions` directive gets very verbose and unsafe,
8484

8585
Relay has supported `@arguments` in its current form since [v2.0](https://github.com/facebook/relay/releases/tag/v2.0.0), released in January 2019. There's now a large body of evidence that allowing fragments to define arguments that can be passed into fragment spreads is a significant usability improvement, and valuable to the wider GraphQL community. However, if we are to introduce this notion more broadly, we should make sure the ergonomics of it conform to users' expectations.
8686

87-
# Proposal: Introduce Fragment Argument Definitions and Fragment Spread Arguments to client-only GraphQL
87+
# Proposal: Introduce Fragment Argument Definitions, which allow using arguments on Fragment Spreads
8888

89-
Relay's `@arguments`/`@argumentDefinitions` concepts provide value, and can be applied against GraphQL written for existing GraphQL servers so long as there is a pre-server compiler which transforms the concept away. However, client-focused tooling, like Prettier and GraphiQL, should also be able to parse and work with these new concepts.
89+
Relay's `@arguments`/`@argumentDefinitions` concepts provide value, and can be applied against GraphQL written for existing GraphQL servers so long as there is a pre-server compiler which transforms the concept away.
9090

9191
## New Fragment Variable Definition syntax
9292

@@ -201,7 +201,6 @@ This validation rule may end up being more strict than required, but it would be
201201

202202
# Implementation
203203

204-
Any client that implements this RFC would have a pre-server compilation step, which transforms all fragment defined variable usages to:
205-
- The passed-in value from a parent fragment spread
206-
- Or if no value is passed in, the default value for the fragment argument definition,
207-
- Or if no default value is defined and no value is passed in, null.
204+
This proposal can be implemented as a compilation step that compiles the user-written GraphQL into a document without fragment arguments. This can eb done in a variety of ways, such as by doing find-variable-replace-with-argument-value or by adding variables on the operation with the argument value set as the default value.
205+
206+
Alternatively, implementations that want to support fragment arguments directly, a naive approach is, when encountering a fragment spread for a fragment with argument definitions, prior to collection that fragment's fields, replace the argument variables with the passed in argument value or default values.

0 commit comments

Comments
 (0)