Skip to content

fix(composition): Don't remove scalar properties in buildSubgraphSchema() when providing resolvers#3285

Merged
sachindshinde merged 2 commits intomainfrom
sachin/fix-subgraph-scalar-resolver-addition
Jun 27, 2025
Merged

fix(composition): Don't remove scalar properties in buildSubgraphSchema() when providing resolvers#3285
sachindshinde merged 2 commits intomainfrom
sachin/fix-subgraph-scalar-resolver-addition

Conversation

@sachindshinde
Copy link
Contributor

@sachindshinde sachindshinde commented Jun 26, 2025

When a GraphQLScalarType is provided in resolvers to buildSubgraphSchema(), its properties overwrite the existing one in the schema created from typeDefs. However, this also includes non-provided/undefined properties, which probably isn't what users expect. This PR updates resolver addition so that undefined properties are skipped; if users want to unset/clear scalar properties, they should use an explicit null for those properties.

@sachindshinde sachindshinde requested a review from a team as a code owner June 26, 2025 19:11
@changeset-bot
Copy link

changeset-bot bot commented Jun 26, 2025

🦋 Changeset detected

Latest commit: 9768a6f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/subgraph Patch
@apollo/federation-internals Patch
@apollo/gateway Patch
@apollo/composition Patch
@apollo/query-planner Patch
@apollo/query-graphs Patch
apollo-federation-integration-testsuite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 26, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@sachindshinde sachindshinde force-pushed the sachin/fix-subgraph-scalar-resolver-addition branch from 9456c41 to 519c6eb Compare June 26, 2025 19:12
@apollo-librarian
Copy link

apollo-librarian bot commented Jun 26, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 2 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/limitations.mdx
* graphos/routing/(latest)/self-hosted/containerization/kubernetes/other-considerations.mdx

Build ID: 0eec616e5629c96d17a4f62c

URL: https://www.apollographql.com/docs/deploy-preview/0eec616e5629c96d17a4f62c

Copy link
Member

@dariuszkuc dariuszkuc left a comment

Choose a reason for hiding this comment

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

Can you add changeset entry?

@sachindshinde sachindshinde requested a review from dariuszkuc June 26, 2025 19:42
@sachindshinde sachindshinde merged commit 4653320 into main Jun 27, 2025
17 checks passed
@sachindshinde sachindshinde deleted the sachin/fix-subgraph-scalar-resolver-addition branch June 27, 2025 18:20
dariuszkuc pushed a commit that referenced this pull request Oct 9, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/composition@2.11.3

### Patch Changes

- Updated dependencies
\[[`8c7a2cd655ad3060e9f5c3b106cfbdb59251701c`](8c7a2cd)]:
    -   @apollo/federation-internals@2.11.3
    -   @apollo/query-graphs@2.11.3

## @apollo/gateway@2.11.3

### Patch Changes

- Updated dependencies
\[[`4faa114215200daf7ad7518be8e50071fcde783c`](4faa114),
[`8c7a2cd655ad3060e9f5c3b106cfbdb59251701c`](8c7a2cd)]:
    -   @apollo/query-planner@2.11.3
    -   @apollo/federation-internals@2.11.3
    -   @apollo/composition@2.11.3

## @apollo/federation-internals@2.11.3

### Patch Changes

- Update connector spec to allow re-entry
([#3312](#3312))

Updates connector spec to follow the same patterns as other federation
spec blueprints (i.e. register types/directives in the constructor and
use default logic for adding them to the schema that checks whether they
need to be added or not).

NOTE: Support for handling input objects in the spec is severely limited
and only handles `@connect` spec. For additional details on limitations
see #3311.

## @apollo/query-graphs@2.11.3

### Patch Changes

- Updated dependencies
\[[`8c7a2cd655ad3060e9f5c3b106cfbdb59251701c`](8c7a2cd)]:
    -   @apollo/federation-internals@2.11.3

## @apollo/query-planner@2.11.3

### Patch Changes

- Fix bug in query planning where a subgraph jump for `@requires` can
sometimes try to fetch `@key` fields from a subgraph that doesn't have
them. This bug would previously cause query planning to error with a
message that looks like "Cannot add selection of field `T.id` to
selection set of parent type `T`".
([#3307](#3307))

- Updated dependencies
\[[`8c7a2cd655ad3060e9f5c3b106cfbdb59251701c`](8c7a2cd)]:
    -   @apollo/federation-internals@2.11.3
    -   @apollo/query-graphs@2.11.3

## @apollo/subgraph@2.11.3

### Patch Changes

- When a `GraphQLScalarType` resolver is provided to
`buildSubgraphSchema()`, omitted configuration options in the
`GraphQLScalarType` no longer cause the corresponding properties in the
GraphQL document/AST to be cleared. To explicitly clear these
properties, use `null` for the configuration option instead.
([#3285](#3285))
([#3285](#3285))

- Updated dependencies
\[[`8c7a2cd655ad3060e9f5c3b106cfbdb59251701c`](8c7a2cd)]:
    -   @apollo/federation-internals@2.11.3

## apollo-federation-integration-testsuite@2.11.3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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