Skip to content

Commit

Permalink
Schema定義を別ファイルに定義
Browse files Browse the repository at this point in the history
  • Loading branch information
keinuma committed Jan 2, 2020
1 parent d17edc8 commit 2dd7692
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion functions/seed/seed-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import MovieData from "./moviedata.json";
admin.initializeApp();

const db = admin.firestore();
MovieData.forEach(async (movie) => {
MovieData.forEach(async movie => {
await db.collection("movies").add(movie);
});
4 changes: 3 additions & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ApolloServer, gql } from "apollo-server-cloud-functions";
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import 'firebase-functions';
import "firebase-functions";

import typeDefs from "@/schema";

admin.initializeApp();

Expand Down
25 changes: 25 additions & 0 deletions functions/src/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { gql } from "apollo-server-cloud-functions";

export default gql`
type Movie {
title: String
year: Int
info: MovieInfo
}
type MovieInfo {
directors: [String]
release_date: String
rating: Float
genres: [String]
image_url: String
plot: String
rank: Int
running_time_secs: Int
actors: [String]
}
type Query {
latestMovies: [Movie]
}
`;

0 comments on commit 2dd7692

Please sign in to comment.