Skip to content

Commit

Permalink
Apollo Serverのサンプルを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
keinuma committed Jan 1, 2020
1 parent b2e1aed commit cd1e9b8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ApolloServer, gql } from "apollo-server-cloud-functions";
import * as functions from 'firebase-functions';

const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.
type Book {
title: String
author: String
}
type Query {
books: [Book]
}
`;

const books = [
{
title: 'Harry Potter and the Chamber of Secrets',
author: 'J.K. Rowling',
},
{
title: 'Jurassic Park',
author: 'Michael Crichton',
},
];

const resolvers = {
Query: {
books: () => books,
},
};

const server = new ApolloServer({ typeDefs, resolvers });

exports.handler = functions.https.onRequest(server.createHandler());

0 comments on commit cd1e9b8

Please sign in to comment.