@@ -155,8 +155,10 @@ describe('merging using type merging', () => {
155
155
// 1. the key for that type will be sent to the resolvers first argument.
156
156
// 2. an array of keys will sent if the resolver returns a list.
157
157
//
158
- // In this example, the `argsExpr` argument for the @merge directive is used to customize
159
- // the arguments that the gateway will pass to the resolver.
158
+ // In this example, the `keyField` argument for the @merge directive is used to customize
159
+ // the portion of the key that the gateway will pass to the resolver.
160
+ //
161
+ // Alternatively, the `argsExpr` argument can be used to allow more customization:
160
162
//
161
163
// Rules for evaluation of these arguments are as follows:
162
164
//
@@ -169,7 +171,8 @@ describe('merging using type merging', () => {
169
171
${ stitchingDirectivesTypeDefs }
170
172
type Query {
171
173
topProducts(first: Int = 2): [Product]
172
- _productsByUpc(upcs: [String!]!): [Product] @merge(argsExpr: "upcs: [[$base.upc]]")
174
+ _productsByUpc(upcs: [String!]!): [Product] @merge(keyField: "upc")
175
+ # EQUIVALENT TO: _productsByUpc(upcs: [String!]!): [Product] @merge(argsExpr: "upcs: [[$key.upc]]")
173
176
}
174
177
type Product @base(selectionSet: "{ upc }") {
175
178
upc: String!
@@ -225,11 +228,12 @@ describe('merging using type merging', () => {
225
228
// 1. the key for that type will be sent to the resolvers first argument.
226
229
// 2. an array of keys will sent if the resolver returns a list.
227
230
//
228
- // In this example, the `argsExpr ` argument for the @merge directive is used to customize
229
- // the arguments that the gateway will pass to the resolver .
231
+ // In this example, the `keyArg ` argument for the @merge directive is used to set the
232
+ // argument to which the gateway will pass the key .
230
233
//
231
- // This example highlights how using the $ sign without dot notation will pass the entire
232
- // key as an object. This allows arbitary nesting of the key input as needed.
234
+ // The equivalent `argsExpr` is also included. This example highlights how when using
235
+ // `argsExpr`, the $ sign without dot notation will pass the entire key as an object.
236
+ // This allows arbitary nesting of the key input as needed.
233
237
//
234
238
typeDefs : `
235
239
${ stitchingDirectivesTypeDefs }
@@ -261,7 +265,8 @@ describe('merging using type merging', () => {
261
265
type Query {
262
266
_reviews(id: ID!): Review
263
267
_users(keys: [UserKey!]!): [User] @merge
264
- _products(input: ProductInput): [Product]! @merge(argsExpr: "input: { keys: [[$key]] }")
268
+ _products(input: ProductInput): [Product]! @merge(keyField: "input.keys")
269
+ # EQUIVALENT TO: _products(input: ProductInput): [Product]! @merge(argsExpr: "input: { keys: [[$key]] }")
265
270
}
266
271
` ,
267
272
resolvers : {
0 commit comments