Skip to content

Feature Request: Support adding cost on types #55

@jvrdelafuente

Description

@jvrdelafuente

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions