Skip to content

Commit 01d4011

Browse files
committed
update integration test
1 parent 40952e6 commit 01d4011

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/stitch/tests/typeMergingWithDirectives.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ describe('merging using type merging', () => {
155155
// 1. the key for that type will be sent to the resolvers first argument.
156156
// 2. an array of keys will sent if the resolver returns a list.
157157
//
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:
160162
//
161163
// Rules for evaluation of these arguments are as follows:
162164
//
@@ -169,7 +171,8 @@ describe('merging using type merging', () => {
169171
${stitchingDirectivesTypeDefs}
170172
type Query {
171173
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]]")
173176
}
174177
type Product @base(selectionSet: "{ upc }") {
175178
upc: String!
@@ -225,11 +228,12 @@ describe('merging using type merging', () => {
225228
// 1. the key for that type will be sent to the resolvers first argument.
226229
// 2. an array of keys will sent if the resolver returns a list.
227230
//
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.
230233
//
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.
233237
//
234238
typeDefs: `
235239
${stitchingDirectivesTypeDefs}
@@ -261,7 +265,8 @@ describe('merging using type merging', () => {
261265
type Query {
262266
_reviews(id: ID!): Review
263267
_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]] }")
265270
}
266271
`,
267272
resolvers: {

0 commit comments

Comments
 (0)