Skip to content

fix: REQUIRED_INACCESSIBLE with default values#299

Merged
kamilkisiela merged 3 commits intomainfrom
fix-required-inaccessible-default-value
Apr 28, 2026
Merged

fix: REQUIRED_INACCESSIBLE with default values#299
kamilkisiela merged 3 commits intomainfrom
fix-required-inaccessible-default-value

Conversation

@n1ru4l
Copy link
Copy Markdown
Contributor

@n1ru4l n1ru4l commented Apr 20, 2026

Fix REQUIRED_INACCESSIBLE composition rule reporting a composition error if @inaccessible is applied on a non-nullable field with a default value.

In the following example schema the Query.ping(message:) argument no longer raises REQUIRED_INACCESSIBLE, as a default value for the argument is provided. The same behaviour applies for input type fields.

extend schema
  @link(
    url: "https://specs.apollo.dev/federation/v2.9"
    import: ["@inaccessible"]
  )

  type Query {
    ping(message: String! = "pong" @inaccessible): String!
  }

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds new test cases to REQUIRED_INACCESSIBLE.spec.ts to verify that the @inaccessible directive is permitted on required arguments and input fields when a default value is provided. The reviewer noted that these tests currently fail and will break the CI pipeline. To address this, it is recommended to either update the RequiredArgumentOrFieldIsNotInaccessibleRule validation logic to check for default values or mark the tests with test.todo() or test.fails() to keep the CI green.

Comment thread __tests__/supergraph/errors/REQUIRED_INACCESSIBLE.spec.ts
@n1ru4l n1ru4l changed the title add failing test for REQUIRED_INACCESSIBLE with default values fix: REQUIRED_INACCESSIBLE with default values Apr 20, 2026
@n1ru4l n1ru4l marked this pull request as ready for review April 20, 2026 11:24
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@theguild/federation-composition 0.22.3-alpha-20260420112644-a174fe2b2b471cb99c3bb99818ca0844b7bf3f0d npm ↗︎ unpkg ↗︎

Copy link
Copy Markdown
Member

@dotansimha dotansimha left a comment

Choose a reason for hiding this comment

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

LGTM. But let's wait for @kamilkisiela 's review as well, as he might have broader context than me on this one :)

@kamilkisiela kamilkisiela merged commit c417891 into main Apr 28, 2026
4 checks passed
@kamilkisiela kamilkisiela deleted the fix-required-inaccessible-default-value branch April 28, 2026 09:20
n1ru4l pushed a commit that referenced this pull request Apr 28, 2026
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
## @theguild/federation-composition@0.22.3

### Patch Changes

-
[#299](#299)
[`c417891`](c417891)
Thanks [@n1ru4l](https://github.com/n1ru4l)! - Fix
`REQUIRED_INACCESSIBLE` composition rule reporting a composition error
if `@inaccessible` is applied on a non-nullable field with a default
value.

In the following example schema the `Query.ping(message:)` argument no
longer raises `REQUIRED_INACCESSIBLE`, as a default value for the
argument is provided. The same behaviour applies for input type fields.

    ```graphql
    extend schema
      @link(
        url: "https://specs.apollo.dev/federation/v2.9"
        import: ["@inaccessible"]
      )

    type Query {
      ping(message: String! = "pong" @inaccessible): String!
    }
    ```

Co-authored-by: github-actions[bot] <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.

3 participants