You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/FragmentArguments.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,9 +84,9 @@ Additionally, the `@argumentDefinitions` directive gets very verbose and unsafe,
84
84
85
85
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.
86
86
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
88
88
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.
90
90
91
91
## New Fragment Variable Definition syntax
92
92
@@ -201,7 +201,6 @@ This validation rule may end up being more strict than required, but it would be
201
201
202
202
# Implementation
203
203
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