@@ -19,40 +19,40 @@ exports.handler = async function(event, context) {
19
19
const schema2 = await getSchema ( "graphql-2" ) ; // other Netlify functions which are graphql lambdas
20
20
const schemas = [ schema1 , schema2 ] ;
21
21
22
- // / **
23
- // * resolving -between- schemas
24
- // * https://www.apollographql.com/docs/graphql-tools/schema-stitching#adding-resolvers
25
- // */
26
- // const linkTypeDefs = `
27
- // extend type Book {
28
- // author: Author
29
- // }
30
- // `
31
- // schemas.push(linkTypeDefs)
32
- // const resolvers = {
33
- // Book: {
34
- // author: {
35
- // fragment: `... on Book { authorName }`,
36
- // resolve(book, args, context, info) {
37
- // return info.mergeInfo.delegateToSchema({
38
- // schema: schema1,
39
- // operation: "query",
40
- // fieldName: "authorByName", // reuse what's implemented in schema1
41
- // args: {
42
- // name: book.authorName,
43
- // },
44
- // context,
45
- // info,
46
- // })
47
- // },
48
- // },
49
- // },
50
- // }
22
+ /**
23
+ * resolving -between- schemas
24
+ * https://www.apollographql.com/docs/graphql-tools/schema-stitching#adding-resolvers
25
+ */
26
+ const linkTypeDefs = `
27
+ extend type Book {
28
+ author: Author
29
+ }
30
+ ` ;
31
+ schemas . push ( linkTypeDefs ) ;
32
+ const resolvers = {
33
+ Book : {
34
+ author : {
35
+ fragment : `... on Book { authorName }` ,
36
+ resolve ( book , args , context , info ) {
37
+ return info . mergeInfo . delegateToSchema ( {
38
+ schema : schema1 ,
39
+ operation : "query" ,
40
+ fieldName : "authorByName" , // reuse what's implemented in schema1
41
+ args : {
42
+ name : book . authorName
43
+ } ,
44
+ context,
45
+ info
46
+ } ) ;
47
+ }
48
+ }
49
+ }
50
+ } ;
51
51
52
52
// more docs https://www.apollographql.com/docs/graphql-tools/schema-stitching#api
53
53
const schema = mergeSchemas ( {
54
- schemas
55
- // , resolvers
54
+ schemas,
55
+ resolvers
56
56
} ) ;
57
57
const server = new ApolloServer ( { schema } ) ;
58
58
return new Promise ( ( yay , nay ) => {
0 commit comments