- 
                Notifications
    You must be signed in to change notification settings 
- Fork 41
Open
Description
Hi. I was wondering if it would make sense to add support for adding cost on the graphql types like this:
type Customer @complexity(value: 5){
  name: String
}
type Employee @complexity(value: 10){
  job: String
}
So for example in the next query, we can specify different complexities based on the type:
query MyQuery {
  People() {
    entities(first: 10) {
      nodes {
        ... on Customer {
          name
        }
        ... on Employee {
          job
        }
      }
    }
  }
}
In the previous example, the cost would be the max complexity of both types, in this case 10.
But for example if I do the query for only Customer like this:
query MyQuery {
 People() {
   entities(first: 10) {
     nodes {
       ... on Customer {
         name
       }
     }
   }
 }
}
The complexity for this query would be 5 instead.
Similar implementation as in this library: graphql-cost-analysis.
I am happy to contribute with a PR, but I wanted to get first your opinion.
Thanks.
orrion
Metadata
Metadata
Assignees
Labels
No labels