Skip to content

Comments

fix(introspection): support @deprecated directive on field arguments#3949

Merged
StevenACoffman merged 1 commit into99designs:masterfrom
AlexanderArvidsson:fix/field-argument-deprecation
Dec 3, 2025
Merged

fix(introspection): support @deprecated directive on field arguments#3949
StevenACoffman merged 1 commit into99designs:masterfrom
AlexanderArvidsson:fix/field-argument-deprecation

Conversation

@AlexanderArvidsson
Copy link
Contributor

@AlexanderArvidsson AlexanderArvidsson commented Dec 2, 2025

Field arguments are currently not introspected as deprecated due to a typo in the field arguments definition in the introspection code. It uses the directives from the field instead of the directives on the field argument:

		for _, arg := range f.Arguments {
			args = append(args, InputValue{
				Type:         WrapTypeFromType(t.schema, arg.Type),
				Name:         arg.Name,
				description:  arg.Description,
				DefaultValue: defaultValue(arg.DefaultValue),
-				deprecation:  f.Directives.ForName("deprecated"),
+				deprecation:  arg.Directives.ForName("deprecated"),
			})

The GraphQL spec was updated in September to allow deprecation on field arguments, and gqlgen seems to have followed, though not working due to the above typo.

I have also added tests, although I must admit I am not entirely sure what the difference is between testserver/singlefile and testserver/followschema. However, I mimicked what I saw from other tests.

I also added introspection tests in the integration/ folder, but running the GraphQL codegen generated code that was unrelated to my changes (perhaps these have not been re-generated for a while, and GraphQL codegen changed?), so I have not included that. I'm open to add those changes to this PR if you're OK with extra stuff being added by codegen.

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@coveralls
Copy link

coveralls commented Dec 3, 2025

Coverage Status

coverage: 0.0%. remained the same
when pulling e015421 on AlexanderArvidsson:fix/field-argument-deprecation
into 9da91b3 on 99designs:master.

@AlexanderArvidsson AlexanderArvidsson force-pushed the fix/field-argument-deprecation branch from 2b450c6 to e015421 Compare December 3, 2025 12:51
@AlexanderArvidsson
Copy link
Contributor Author

Fixed the linting, I did not see it because I had v1 of golangci-lint instead of v2 which caused it to not run in Neovim 😓

@StevenACoffman
Copy link
Collaborator

Thanks for this! I could also use help updating https://github.com/vektah/gqlparser (which gqlgen relies on) to the latest spec update.

@StevenACoffman StevenACoffman merged commit 9aa9cd5 into 99designs:master Dec 3, 2025
18 checks passed
@AlexanderArvidsson
Copy link
Contributor Author

Thanks for this! I could also use help updating https://github.com/vektah/gqlparser (which gqlgen relies on) to the latest spec update.

I might have a look if I find some time, am happy to help!
This one case I only found when deprecating a field and wondering why my introspected schema didn't include it.

@StevenACoffman
Copy link
Collaborator

@AlexanderArvidsson If you get a chance, vektah/gqlparser#401 is where I started to update it, and then there are just various test failures to work through. Anything you can contribute would be a huge help!

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