GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Validation of deprecated non-nullable non-default argument is not correct · Issue #4182 · graphql-java/graphql-java

Validation of deprecated non-nullable non-default argument is not correct #4182

New issue
Copy link
New issue
Copy link
Closed
Closed
Validation of deprecated non-nullable non-default argument is not correct#4182
Copy link
Labels
Stale

Description

@Blemicek
Blemicek
opened on Dec 1, 2025
Issue body actions

Describe the bug
GraphQL specification prohibits deprecation directive on non-nullable arguments without a default value, but graphql-java allows creation of such schema programmatically although there is validation (DeprecatedInputObjectAndArgumentsAreValid) that should prevent that.

Let say a new argument is created like this:

GraphQLArgument deprecatedArg = GraphQLArgument.newArgument()
  .name("argument")
  .type(GraphQLNonNull.nonNull(Scalars.GraphQLString))
  .deprecate("Some very good reason")
  .build();

The validation then tries to find deprecated applied directive:

graphql-java/src/main/java/graphql/schema/validation/DeprecatedInputObjectAndArgumentsAreValid.java

Line 46 in aa0b31e

GraphQLAppliedDirective deprecatedDirective = argument.getAppliedDirective(Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName());

But deprecatedDirective is null, and so it's reported as valid schema. The fix seems to be calling of argument.isDeprecated(), or combination of both approaches.

To Reproduce

GraphQLArgument deprecatedArg = GraphQLArgument.newArgument()
        .name("input")
        .type(GraphQLNonNull.nonNull(Scalars.GraphQLString))
        .deprecate("Some very good reason")
        .build();

GraphQLFieldDefinition field = GraphQLFieldDefinition.newFieldDefinition()
        .name("field")
        .type(Scalars.GraphQLString)
        .argument(deprecatedArg)
        .dataFetcher(env -> env.getArgument("input")) // for simplicity
        .build();

GraphQLObjectType queryType = GraphQLObjectType.newObject()
        .name("Query")
        .field(field)
        .build();

GraphQLSchema.newSchema()
        .query(queryType)
        .build(); // this method internally do the validation and should throw exception

Equivalent schema (implicit parts are omitted):

type Query {
  field(input: String! @deprecated(reason : "Some very good reason")): String
}

Activity

  1. bbakerman commented on Dec 18, 2025

    @bbakerman
    bbakerman
    on Dec 18, 2025
    Member
    More actions

    Ok I had a look at this and I know the reason its failing.

    When types are created via SDL then code kicks in that notices the @deprecatedArg directive and then calls graphql.schema.GraphQLArgument.Builder#deprecate to set the deprecation string into the argument

    However the DeprecatedInputObjectAndArgumentsAreValid validation code only looks for the actual directive. This is present in the case of SDL build schema but not direct like this.

    I will think more on how we can fix it.

  2. bbakerman
    added 2 commits that reference this issue on Dec 18, 2025

    #4182 - code built schemas should perform deprecated non null field v…

    afbcd52

    #4182 - code built schemas should perform deprecated non null field v…

    dd5bc03
  3. bbakerman commented on Dec 18, 2025

    @bbakerman
    bbakerman
    on Dec 18, 2025
    Member
    More actions

    Fixed

    Reacted by Petr Fanta
  4. andimarek
    added a commit that references this issue on Jan 21, 2026

    Merge pull request #4194 from graphql-java/4182-deprecated-non-null-a…

    1a80205
  5. github-actions commented on Feb 17, 2026

    @github-actions
    github-actionsBot
    on Feb 17, 2026 – with GitHub Actions
    Contributor
    More actions

    Hello, this issue has been inactive for 60 days, so we're marking it as stale. If you would like to continue this discussion, please comment within the next 30 days or we'll close the issue.

  6. github-actions
    added
    Stale
    on Feb 17, 2026
  7. bbakerman commented on Feb 18, 2026

    @bbakerman
    bbakerman
    on Feb 18, 2026
    Member
    More actions

    Done

  8. bbakerman
    closed this as completedon Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.