rover
rover copied to clipboard
Offline `rover fields-usage` command
Description
To get a better understanding of how the schema is used, it would be useful to have a command that checks a list of .graphql
operation files against a schema
Example usage
> rover fields-usage schema.graphqls operation1.graphql operation2.graphql ... operationN.graphql
type Query {
hero (3)
search (8)
}
type Character {
name (3)
email (2)
appearsIn (0)
}
[...]
Where the output is the different schema types annotated with their respective usage count.
This could be run in CI to monitor the schema usage across different clients and for an example detect unused fields so that they can be scheduled for deprecation. Or together with schema checks to make sure a currently used field is never deleted.
I think that it might also be useful to be able to output a report with the usages locations, but I am not sure what would be a good format for this output.
Makes sense. Maybe aim for json as an output then? And store the path of all usages?
[
{
"name": "Query",
"fields": {
"hero": [
"GetCharacterQuery.hero"
]
}
},
{
"name": "Character",
"fields": {
"name": [
"GetCharacterQuery.hero.name",
"GetCharacterQuery.hero.friends.name",
"GetCharacterQuery.search.name"
],
"appearsIn": []
}
}
]