Warn on deprecated fields
How hard would it be to have apollo-codegen emit warnings (or fail) during the generate phase when one of your queries is using deprecated fields?
If you're open to the idea and can give some guidance on how to go about it, we'd try to create a PR.
We already generate appropriate code for Swift and Android for deprecated fields, so these show up as warnings during compilation. I don't think TypeScript or Flow support deprecation annotations however.
You could try adding a validation rule for this, but failing codegen seems too drastic to me.
Hi @martijnwalraven, I guess TypeScript doesn't support deprecation annotations like
@available(*, deprecated, message: "deprecation message") in Swift. Then how about showing deprecated fields warnings directly in the terminal/console when running generate command?
@martijnwalraven - We are using the iOS Apollo library with a GraphQL db. We have deprecated some properties, but these do not generate warnings in Xcode when generating code. Has this function been removed from the code generation, or do we need to do something to enable it?
We're using Xcode 10.2.1 with Apollo 0.10.1 installed via CocoaPods.
Here's an example from our schema.json
"name": "coverImage",
"description": "Deprecated",
"args": [],
"type": { "kind": "OBJECT", "name": "SignedUrl", "ofType": null },
"isDeprecated": true,
"deprecationReason": "Cover images are not used on tags."
}```
Which is generating this code
```/// Deprecated
public var coverImage: CoverImage? {
get {
return (resultMap["coverImage"] as? ResultMap).flatMap { CoverImage(unsafeResultMap: $0) }
}
set {
resultMap.updateValue(newValue?.resultMap, forKey: "coverImage")
}
}