graphql-spec icon indicating copy to clipboard operation
graphql-spec copied to clipboard

Add ARGUMENT in DirectiveLocation

Open dugenkui03 opened this issue 3 years ago • 2 comments

I think it will be great if ARGUMENT will be allowed in DirectiveLocation, and ARGUMENT means that user can user directive on argument in query.

That is the scene: we want to divide list argument into groups by size, and get the field value respectively, then merge the result into result list.

  1. schema type definition:
Type Query{
     itemList(itemIds: [Int]): [Item]
}

Type Item{
      id: ID
      price: Int
}
  1. ARGUMENT definition:
directive @partition(size: Int) on ARGUMENT
  1. use @partition in query:
query getTooManyItemByIds(itemIds:[Int]){
      itemList(itemIds:$itemIds @partition(size:5)){
             id
             price
      }
} 

dugenkui03 avatar Feb 14 '22 16:02 dugenkui03

+1 for the idea; but sample case is not good IMHO

rivantsov avatar Feb 14 '22 18:02 rivantsov

Adding the ability to specify a directive on an input-object field (within the query document, not the input object field definition) would be useful as well.

SpencerMacKinnon avatar Feb 17 '22 21:02 SpencerMacKinnon