forked from ddebarros/sample-functions-apollo-graphql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
44 lines (39 loc) · 1.18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { ApolloServer } from './ApolloServer';
import { ApolloServerPluginLandingPageGraphQLPlayground, gql } from 'apollo-server-core'
// Construct a schema, using GraphQL schema language
const typeDefs = gql`
type User {
first_name: String!
last_name: String!
emails: String
}
type Query {
GetUser: User
}
`;
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
GetUser: (args1: any, args2: any, args3: any) => {
console.log(args1, args2, args3)
return {
first_name: 'John',
last_name: 'Doe',
email: '[email protected]'
}
},
},
};
const server = new ApolloServer({
typeDefs,
resolvers,
// By default, the GraphQL Playground interface and GraphQL introspection
// is disabled in "production" (i.e. when `process.env.NODE_ENV` is `production`).
//
// If you'd like to have GraphQL Playground and introspection enabled in production,
// install the Playground plugin and set the `introspection` option explicitly to `true`.
introspection: true,
plugins: [ApolloServerPluginLandingPageGraphQLPlayground()],
});
const handler = server.createHandler();
export const main = handler;