absinthe-graphql / absinthe

The GraphQL toolkit for Elixir
http://absinthe-graphql.org
Other
4.27k stars 526 forks source link

Mix.Tasks.Absinthe.Schema.Json nolonger includes deprecated input fields #1327

Open jweinkam opened 1 month ago

jweinkam commented 1 month ago

If submitting a bug, please provide the following:

Environment

Expected behavior

In prior versions, when running

  mix absinthe.schema.json --schema MyApp.Schema --json-codec AbsintheSortingCodec --pretty ./schema.json > /dev/null

the generated schema.json file would contain input fields that were marked as deprecated.

Actual behavior

In this version, running the same task omits the deprecated input fields. No errors are display.

Relevant Schema/Middleware Code

Hacking the absinthe/priv/graphql/introspection.graphql file at line 44 to be inputFields(includeDeprecated: true) { instead of just inputFields { adds back the deprecated input fields.

matt-savvy commented 1 month ago

We found that default values for :include_deprecated do not seem to be making it to the :resolve functions. Setting the default value true, if I drop in an IO.inspect, the output is still showing false.

For example: https://github.com/absinthe-graphql/absinthe/blob/5705d9a0e16bf425d29f5fc7a945bbff4d751ec5/lib/absinthe/type/built_ins/introspection.ex#L78

matt-savvy commented 1 month ago

Our solution was to copy the introspection.graphql file to our own repo and explicitly add includeDeprecated: true like mentioned above for args, fields, and inputFields. This got our schema dumps back to the behavior as it was in 1.7.6

rossvz commented 1 month ago

We just ran into this after updating from 1.7.6 to 1.7.8 - this feels like a major breaking change since it now hard-removes deprecated fields from the schema. This sort of bypasses the reason to use deprecation in the first place - since the effect is equivalent to just deleting the field entirely. @benwilson512 this change was also not documented anywhere in the CHANGELOG for 1.7.7 which feels risky?

benwilson512 commented 1 month ago

Hey @rossvz as implied by the earlier comments, this appears to be a bug, not an intended change. I do not have time to look into this this week but am happy to review any PRs that take a swing at resolving the issue.

rossvz commented 1 month ago

@jgautsch I'm curious if you have ideas here, I think you were the author for https://github.com/absinthe-graphql/absinthe/pull/1291. Is there anything we need to add on the absinthe side to make this work?

We're using graphql-codegen to generate schema files for our Apollo client, but nothing on the client config side seems to get these fields to appear.

jgautsch commented 1 month ago

@rossvz aside from that PR I'm distant from it enough to probably not be of much help. It looks like setting the default value for includeDeprecated arg to true would fix your issue but maybe wouldn't be in line with the spec. Otherwise the only thing I'd think to do would be to modify your queries, but I'm sure you've thought of that so prob not helpful. I too use graphql-codegen but don't use any deprecated fields. Godspeed!