Title: GitHub · Where software is built
Open Graph Title: graphql-java/graphql-java
X Title: graphql-java/graphql-java
Description: GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub.
Open Graph Description: GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub.
X Description: GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub.
Opengraph URL: https://github.com/graphql-java/graphql-java
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Validation of deprecated non-nullable non-default argument is not correct","articleBody":"**Describe the bug**\nGraphQL specification [prohibits](https://github.com/graphql/graphql-spec/blob/September2025/spec/Section%203%20--%20Type%20System.md?plain=1#L2271-L2284) 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. \n\nLet say a new argument is created like this:\n```\nGraphQLArgument deprecatedArg = GraphQLArgument.newArgument()\n .name(\"argument\")\n .type(GraphQLNonNull.nonNull(Scalars.GraphQLString))\n .deprecate(\"Some very good reason\")\n .build();\n```\nThe validation then tries to find `deprecated` applied directive:\nhttps://github.com/graphql-java/graphql-java/blob/aa0b31ebf28fdbf17d659800f6e8e6e1381dde50/src/main/java/graphql/schema/validation/DeprecatedInputObjectAndArgumentsAreValid.java#L46\n\nBut `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. \n\n**To Reproduce**\n\n```\nGraphQLArgument deprecatedArg = GraphQLArgument.newArgument()\n .name(\"input\")\n .type(GraphQLNonNull.nonNull(Scalars.GraphQLString))\n .deprecate(\"Some very good reason\")\n .build();\n\nGraphQLFieldDefinition field = GraphQLFieldDefinition.newFieldDefinition()\n .name(\"field\")\n .type(Scalars.GraphQLString)\n .argument(deprecatedArg)\n .dataFetcher(env -\u003e env.getArgument(\"input\")) // for simplicity\n .build();\n\nGraphQLObjectType queryType = GraphQLObjectType.newObject()\n .name(\"Query\")\n .field(field)\n .build();\n\nGraphQLSchema.newSchema()\n .query(queryType)\n .build(); // this method internally do the validation and should throw exception\n```\n\nEquivalent schema (implicit parts are omitted):\n```\ntype Query {\n field(input: String! @deprecated(reason : \"Some very good reason\")): String\n}\n```\n","author":{"url":"https://github.com/Blemicek","@type":"Person","name":"Blemicek"},"datePublished":"2025-12-01T19:50:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/4182/graphql-java/issues/4182"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:f5682ff1-2c26-f1a6-ca39-c112c7dfd7b1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C972:2DEF11:55133E:78DB43:696F84C9 |
| html-safe-nonce | bc9c57c7106a5d564e2b17d6e20f6e01b9bf81579e7f65a8d80783635f7938b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTcyOjJERUYxMTo1NTEzM0U6NzhEQjQzOjY5NkY4NEM5IiwidmlzaXRvcl9pZCI6IjQxMjU4ODI2Njg3Nzc3MDI2MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3b8bf644fc09b9949a3169bb4680eee832d1c89a8ee00498bcbf4dab99557047 |
| hovercard-subject-tag | repository:38602457 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/issues/4182 |
| twitter:image | https://opengraph.githubassets.com/0c13f74bf56ef9481083b996ed372a8c4e69475deea920c1e7cab971eeb3c3f5/graphql-java/graphql-java |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0c13f74bf56ef9481083b996ed372a8c4e69475deea920c1e7cab971eeb3c3f5/graphql-java/graphql-java |
| og:image:alt | GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | c1b02b4e3a8edff2fe0bd71b0551654be66034591c7ab65aaaaf61a6096862d3 |
| turbo-cache-control | no-cache |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a1073fcc34432ac33cec03885ff2d96920686de |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width