Skip to content

Add support for service capabilities#6858

Merged
martinbonnin merged 9 commits into
mainfrom
capabilities
Jan 28, 2026
Merged

Add support for service capabilities#6858
martinbonnin merged 9 commits into
mainfrom
capabilities

Conversation

@martinbonnin

Copy link
Copy Markdown
Contributor

See graphql/graphql-spec#1208

The parser has good tests. Introspection/execution still need a bit more tests but since this is RFC1, I expect things to change a bit and I don't want to spend too much time updating every test.

@martinbonnin
martinbonnin requested a review from BoD as a code owner January 28, 2026 11:09
@apollo-librarian

apollo-librarian Bot commented Jan 28, 2026

Copy link
Copy Markdown

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 2a5885ec89f213c74fb4619d
Build Logs: View logs

@martinbonnin martinbonnin changed the title Add support for Service capabilities Add support for service capabilities Jan 28, 2026
Comment thread libraries/apollo-ast/api/apollo-ast.api
Comment on lines +43 to +44
* TODO: This is potentially an issue because it means adding new features changes the output of this function.
* For an example, it doesn't support service capabilities as of now to avoid confusing other external tools.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why we need the SDL -> JSON transformation. For interop, this is an issue because different tools may not support all the introspection features.

I decided to not add support for service capabilities there and more generally moving forward, probably deprecating this functionality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed this should probably be deprecated, I can't think of a use-case for it. Ah except maybe to generate fixtures for our own tests? Meh.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, if the only usage is tests, this is not enough. People may be using the CLI to convert to JSON, not 100% sure why they would do this but that's a possibility.

There's no rush. We can keep it untouched for now.

@BoD BoD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉


expectKeyword("service")
val directives = parseDirectives(const = true)
val capabilities = parseNonEmptyList<Token.LeftBrace, Token.RightBrace, GQLCapability> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

According to the spec the list can be empty, but actually I think the spec should be + because an empty block doesn't make much sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, I remember that discussion. There are multiple issues of people wanting to have empty objects/selection sets and IIRC, @benjie used capabilities as a place to toy with empty blocks. I'll update that code so that it matches the current PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Specifically, Lee said we should allow empty blocks here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, that works for me 👍

parseServiceCapability()
}.orEmpty()

if (directives.isEmpty() && capabilities.isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, this makes sense but doesn't match the current spec.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll keep this in line with the current spec PR but while I think it makes sense for the definition, I'm not sure about the extension. Asked the question there

Comment on lines +43 to +44
* TODO: This is potentially an issue because it means adding new features changes the output of this function.
* For an example, it doesn't support service capabilities as of now to avoid confusing other external tools.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed this should probably be deprecated, I can't think of a use-case for it. Ah except maybe to generate fixtures for our own tests? Meh.

Comment thread libraries/apollo-tooling/src/main/resources/base-introspection.graphql Outdated
@martinbonnin
martinbonnin merged commit fdaf623 into main Jan 28, 2026
7 checks passed
@martinbonnin
martinbonnin deleted the capabilities branch January 28, 2026 14:17
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.

3 participants