Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit f92e2b3

Browse files
author
sw-yx
committed
drop resolvers field in graphql gateway
1 parent b58cc79 commit f92e2b3

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/functions-templates/js/graphql-gateway/graphql-gateway.js

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
/**
22
* This code assumes you have other graphql Netlify functions
33
* and shows you how to stitch them together in a "gateway".
4-
*
4+
*
55
* Of course, feel free to modify this gateway to suit your needs.
66
*/
77

8-
98
const {
109
introspectSchema,
1110
makeRemoteExecutableSchema,
12-
mergeSchemas,
13-
} = require("graphql-tools")
14-
const { createHttpLink } = require("apollo-link-http")
15-
const fetch = require("node-fetch")
16-
const { ApolloServer, gql } = require("apollo-server-lambda")
11+
mergeSchemas
12+
} = require("graphql-tools");
13+
const { createHttpLink } = require("apollo-link-http");
14+
const fetch = require("node-fetch");
15+
const { ApolloServer, gql } = require("apollo-server-lambda");
1716

1817
exports.handler = async function(event, context) {
19-
const schema1 = await getSchema("graphql-1") // other Netlify functions which are graphql lambdas
20-
const schema2 = await getSchema("graphql-2") // other Netlify functions which are graphql lambdas
21-
const schemas = [schema1, schema2]
18+
const schema1 = await getSchema("graphql-1"); // other Netlify functions which are graphql lambdas
19+
const schema2 = await getSchema("graphql-2"); // other Netlify functions which are graphql lambdas
20+
const schemas = [schema1, schema2];
2221

2322
// /**
2423
// * resolving -between- schemas
@@ -51,22 +50,25 @@ exports.handler = async function(event, context) {
5150
// }
5251

5352
// more docs https://www.apollographql.com/docs/graphql-tools/schema-stitching#api
54-
const schema = mergeSchemas({ schemas, resolvers })
55-
const server = new ApolloServer({ schema })
53+
const schema = mergeSchemas({
54+
schemas
55+
// ,resolvers
56+
});
57+
const server = new ApolloServer({ schema });
5658
return new Promise((yay, nay) => {
57-
const cb = (err, args) => (err ? nay(err) : yay(args))
58-
server.createHandler()(event, context, cb)
59-
})
60-
}
59+
const cb = (err, args) => (err ? nay(err) : yay(args));
60+
server.createHandler()(event, context, cb);
61+
});
62+
};
6163

6264
async function getSchema(endpoint) {
6365
// you can't use relative URLs within Netlify Functions so need a base URL
6466
// process.env.URL is one of many build env variables:
6567
// https://www.netlify.com/docs/continuous-deployment/#build-environment-variables
6668
// Netlify Dev only supports URL and DEPLOY URL for now
67-
const uri = process.env.URL + "/.netlify/functions/" + endpoint
68-
const link = createHttpLink({ uri, fetch })
69-
const schema = await introspectSchema(link)
70-
const executableSchema = makeRemoteExecutableSchema({ schema, link })
71-
return executableSchema
72-
}
69+
const uri = process.env.URL + "/.netlify/functions/" + endpoint;
70+
const link = createHttpLink({ uri, fetch });
71+
const schema = await introspectSchema(link);
72+
const executableSchema = makeRemoteExecutableSchema({ schema, link });
73+
return executableSchema;
74+
}

0 commit comments

Comments
 (0)