Enable 'schema' keyword to be provided without root operations
At a glance​
- Identifier: #1166
- Stage: RFC0: Strawman
- Champion: @benjie
- PR: Enable 'schema' keyword to be provided without root operations
Timeline​
- Spec PR created on 2025-05-01 by benjie
- Added to 2025-05-01 WG agenda
- Commit pushed: Enable 'schema' keyword to be provided without root operations on 2025-04-30 by @benjie
This PR is motivated by:
- #1163
In the above PR we want to be able to indicate the error propagation behavior of a schema. However, I find it displeasing that to do so we would need to also explicitly detail the operations supported by the schema when they would normally be auto-detected based on their names:
+schema @behavior(onError: NO_PROPAGATE) {
+ query: Query
+ mutation: Mutation
+ subscription: Subscription
+}
+
type Query {
q: Int
}
type Mutation {
m: Int
}
type Subscription {
s: Int
}This PR makes it so that you can use a schema keyword to add directives and/or description to the schema without needing to also specify the root operation types if they can be inferred by the default naming. The above diff would thus become:
+schema @behavior(onError: NO_PROPAGATE)
+
type Query {
q: Int
}
type Mutation {
m: Int
}
type Subscription {
s: Int
}Much nicer! ✨
This is also useful without the
onError
feature, since it allows you to apply a description to a schema without having to detail the operations:+"""Just an example"""
+schema
+
type Query {
q: Int
}
type Mutation {
m: Int
}
type Subscription {
s: Int
}PR #1164 applies these changes onto #1163; but this PR is mergeable into the spec as-is.