Skip to content

feat(compiler, parser): support executable document descriptions #974

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Jul 2, 2025

Support for parsing and serializing descriptions on:

  • (longhand) operation definitions
  • fragment definitions
  • variable definitions

As described by the latest GraphQL spec draft: graphql/graphql-spec#1170

Adding a description on a query shorthand (bare braced selection set) raises a parse error.

This is a breaking change for apollo-compiler due to the addition of new fields:

  • apollo_compiler::ast::OperationDefinition::description
  • apollo_compiler::ast::FragmentDefinition::description
  • apollo_compiler::ast::VariableDefinition::description
  • apollo_compiler::executable::Operation::description
  • apollo_compiler::executable::Fragment::description

For most users, adding description: None anywhere they create one of these structures is good enough.

Todos

  • Formatting improvements for variable definitions with descriptions (steal what we do for argument definitions)

Support for parsing and serializing descriptions on:
- (longhand) operation definitions
- fragment definitions
- variable definitions

As described by the latest GraphQL spec draft: graphql/graphql-spec#1170

Adding a description on a query shorthand (bare braced selection set) raises a
parse error.

This is a breaking change for apollo-compiler due to the addition of new fields:
- `apollo_compiler::ast::OperationDefinition::description`
- `apollo_compiler::ast::FragmentDefinition::description`
- `apollo_compiler::ast::VariableDefinition::description`
- `apollo_compiler::executable::Operation::description`
- `apollo_compiler::executable::Fragment::description`

For most users, adding `description: None` anywhere they create one of these
structures is good enough.
@goto-bus-stop goto-bus-stop requested a review from a team as a code owner July 2, 2025 08:00
Copy link
Member

@lrlna lrlna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

The only thing that needs to change is that the new file in apollo-compiler/test_data/diagnostics is missing it's matching .txt pair. Other comments are clarification questions.

Since this is a breaking change for the compiler, do we need to have a conversation about what should go into the next major version of the compiler (if there is anything)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this missing a matching .txt file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, should we have this test case in the parser's test_data directory for posterity?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also have this test case in the parser's test_data directory for posterity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@lrlna
Copy link
Member

lrlna commented Jul 3, 2025

Since this is a breaking change for the compiler, do we need to have a conversation about what should go into the next major version of the compiler (if there is anything)?

I reviewed the PR before seeing your message in slack asking the exact same thing. Carry on!

@@ -33,6 +41,11 @@ pub(crate) fn variable_definitions(p: &mut Parser) {
/// Variable **:** Type DefaultValue? Directives[Const]?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goto-bus-stop Update these comments

@@ -25,6 +25,7 @@ pub struct FragmentDef {
impl From<FragmentDef> for ast::Definition {
fn from(x: FragmentDef) -> Self {
ast::FragmentDefinition {
description: None, // TODO(@goto-bus-stop): represent description
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goto-bus-stop fix these things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants