rover icon indicating copy to clipboard operation
rover copied to clipboard

Add support for @deprecated on input fields

Open benweatherman opened this issue 3 years ago • 8 comments

It's officially part of the spec so rover should support it as well. Others have gone through similar additions for @deprecated support https://github.com/apollographql/router/pull/1452

We can now see @deprecated on the ProductQueryInput input below:

➜ cargo rover graph introspect http://localhost:4000
    Finished dev [unoptimized + debuginfo] target(s) in 0.24s
     Running `target/debug/rover graph introspect 'http://localhost:4000'`
Introspection Response: 

type Product {
  upc: String!
  name: String @deprecated(reason: "We no longer care about the product name")
  price: Int
}
type Query {
  product(productQuery: ProductQueryInput): Product
}
input ProductQueryInput {
  upc: String
  name: String @deprecated(reason: "We really no longer care about the product name")
  price: Int
}
"Exposes a URL that specifies the behavior of this scalar."
directive @specifiedBy(
    "The URL that specifies the behavior of this scalar."
    url: String!
  ) on SCALAR

Fixes #1209

benweatherman avatar Aug 02 '22 19:08 benweatherman

Agreed there'd be an issue introspecting something that doesn't support includeDeprecated for inputs. Using 2-phase introspection makes sense.

benweatherman avatar Aug 02 '22 21:08 benweatherman

I got my hands on one of these servers that don't support includeDeprecated on __Input, so I'll make sure rover still supports that.

benweatherman avatar Aug 03 '22 14:08 benweatherman

Even though I got my hands on a subgraph server to replicate the issue, I don't quite know how to make it work. Part of it is making a decent design, the other is making it work with my feeble rust skills.

  1. Is there a way around making 2 requests to get all the info we want? At least for the server I'm testing with, there's not a way to make a single request to optionally get input field deprecation info (it fails with a parse error if I try to include the includeDeprecated param)
  2. If 2 requests seems like the only path, do we make the original request and then request with only the inputFields(includeDeprecated: true) fields and the isDeprecated & deprecationReason selection, then add it to the original query data?

benweatherman avatar Aug 10 '22 14:08 benweatherman

that sounds like a reasonable approach to me!

as for how to combine that - you'll want a struct with the includeDeprecated as an Option - and on the second request, set that field to Some if it exists and leave it None if it doesnt

EverlastingBugstopper avatar Aug 10 '22 16:08 EverlastingBugstopper

I wonder if @IvanGoncharov has any thoughts here.

abernix avatar Aug 11 '22 16:08 abernix

This may not be helpful at all but would the @include(if: $someFlag) decorator be useful to restrict when asking for the input field deprecations?

kdawgwilk avatar Aug 11 '22 17:08 kdawgwilk

Would it be worth adding support for includeDeprecated on args in this PR too? The referenced PR (https://github.com/apollographql/router/pull/1452) also includes args, so it'd be nice to get that in too <3

notjosh avatar Aug 24 '22 14:08 notjosh

If anyone else would be interested in picking this up and move it across the line, please feel free!

abernix avatar Aug 25 '22 16:08 abernix

@abernix Any movement on this? I'd love to see Rover adopt this addition to the spec so teams can more confidently ship changes to their mutations that (at my org) rely heavily on Input objects

YouGoJoe avatar Oct 25 '22 13:10 YouGoJoe

This PR needs to be landed in introspector-gadget instead, follow this issue for updates.

EverlastingBugstopper avatar Oct 31 '22 16:10 EverlastingBugstopper