graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

WIP: Warn on deprecated member usage

Open jturkel opened this issue 5 years ago • 0 comments

This PR adds warning reporting when GraphQL documents reference deprecated schema members. We're using something similar at Salsify so I thought I'd see if you're interested in adding to this gem. Here's an example query that uses a deprecated Product.thumbnail field:

ProductQuery = ProductService::Client.parse <<-'GRAPHQL'
  query($sku: String!) {
    product(sku: $sku) {
      name
      thumbnail
    }
  }
GRAPHQL

The following warning will be printed to stderr which includes the field coordinates, deprecation reason and corresponding line in the Ruby source file:

GRAPHQL DEPRECATION WARNING: Product.thumbnail is deprecated with reason: 'Use Product.thumbnailUrl instead': main.rb:5

In the future we could make the handling of deprecations pluggable so applications can customize the reporting behavior.

@rmosolgo / @jhawthorn - Let me know if you have any interest in adding this functionality to this gem and I'd be happy to finish up the PR.

jturkel avatar Jul 09 '20 19:07 jturkel