-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add field usage query analyzer #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add field usage query analyzer #245
Conversation
👍 love it! I have a few thoughts:
|
I'm not sure if you'd want to add a query error. Deprecated fields are meant to be an intermediary state between a field that is available and a field that is removed, no? I believe client libraries should add a warning log when a deprecated field is being queried. What I meant by "resurfaced to API consumers" was something like a weekly e-mail to API consumers "Your app is using X, Y, Z deprecated fields" or via an admin panel that API consumers have access to.
👍 Absolutely!
Good question. I hadn't thought of that as I'm mostly interested in logging all deprecated fields and all used fields and this data is then processed by another system which is why I went with strings.
Edit: We could maybe just go with |
ac71d6b
to
6b024a3
Compare
Yes, I guess you're right about errors, that's not really a good way to communicate the deprecation thing. Happy to leave One last thought: Right now this uses {
node(id: $myNodeId) {
... on Cheese { id }
... on Milk { id }
}
} I think this would cause:
That seems right to me: from the query analysis point of view, you don't know which objects will be used at runtime, so you have to mark both as used. And if either one is deprecated, then you want to know, since it is present in the query. Does that sound right to you, is that what you had in mind also? |
🤘 |
🎉 We should probably revisit this once #186 (comment) has landed. |
🚢 in 0.18.12 |
Follow up from a discussion over Slack with @rmosolgo.
When maintaining a GraphQL API it's important to know what fields are being used, especially deprecated fields.
This adds a simple query analyzer that exposes both
used_fields
andused_deprecated_fields
.These arrays can then be fed into other systems in order to know if removing a deprecated field is safe and resurfaced to API consumers to let them know they are using a deprecated field.
I'm not sure if this belongs in the repo, but at the very least could serve as an example in docs for someone wanting to build a query analyzer.
@rmosolgo any thoughts?