Skip to content

Commit ced6f6f

Browse files
authored
Feature Discovery RFC (#1370)
1 parent 25e1b01 commit ced6f6f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

rfcs/FeatureDiscovery.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# RFC: Feature Discovery
2+
3+
**Proposed by:**
4+
5+
- [Young Min Kim](https://github.com/aprilrd) - The Trade Desk
6+
7+
This RFC provides a way for the clients to determine if a GraphQL server supports a feature that cannot be discovered through the current GraphQL introspection functionality.
8+
9+
## 📜 Problem Statement
10+
11+
Thus far, a GraphQL client could use the [schema introspection](https://spec.graphql.org/draft/#sec-Schema-Introspection.Schema-Introspection-Schema) to check if a feature is available on a server. For example, a client can discover Defer/Stream through the `directives` field and Input Union through the `mutationType` field.
12+
13+
However, some new GraphQL features such as Client Controlled Nullability, Fragment Arguments, and Fragment Modularity change the syntax of the GraphQL documents, which cannot be described via the existing schema introspection. We would like a way to describe a server's supported feature set in an unambigous way.
14+
15+
## ✅ RFC Goals
16+
17+
- A unambigous way to describe a supported feature set
18+
- Open a path for developer tools to validate documents based on the target server's supported features
19+
20+
## 🚫 RFC Non-goals
21+
22+
- TBD
23+
24+
## 🗿 Prior Art
25+
26+
A GraphQL client can choose to test the support by requesting a document with the specific feature and checking errors in response. However, this method requires a client to understand how a server can fail given a specific unsupported feature; how a server returns an error for an unknown syntax (`Syntax Error: Expected Name, found !`) is different from how a server returns an error for an unknown directive (`Unknown directive "defer".`). So the status quo is not acceptable.
27+
28+
## Related Issues
29+
30+
* Client Controlled Nullability: https://github.com/graphql/graphql-spec/pull/895
31+
* Fragment Arguments: https://github.com/graphql/graphql-spec/pull/865
32+
* Fragment Modularity: https://github.com/graphql/graphql-wg/pull/839
33+
34+
## 🧑‍💻 Proposed Solution
35+
36+
TBD
37+
38+
### Option A: Extending a schema for schema introspection
39+
40+
We can add a new field `__features` under the `__Schema` type. `__features` can return a list of features in some shape.
41+
42+
### Option B: Add a new root-level meta field next to `__schema` and `__type`
43+
44+
`__feature` will take an argument for a feature name such as `non-nullable-designator`` and returns _some info_ or `null`.
45+
46+
### Option C: TBD
47+

0 commit comments

Comments
 (0)