Skip to content

Commit

Permalink
local graphql server 띄움
Browse files Browse the repository at this point in the history
  • Loading branch information
daheeahn committed Apr 9, 2020
1 parent 6405aeb commit f0910da
Show file tree
Hide file tree
Showing 4 changed files with 3,560 additions and 56 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"@babel/node": "^7.8.7",
"@babel/preset-env": "^7.9.5",
"@nexus/schema": "^0.13.1",
"apollo-server": "^2.12.0",
"global": "^4.4.0",
"graphql": "^15.0.0",
"nexus": "^0.12.0",
"nodemon": "^2.0.3",
"prisma": "^1.34.10",
"typescript": "^3.8.3"
},
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/graphql/resolvers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
Query: {
dahee: (_: any, __: any, { some }) => {
console.log(some);
return "I am dahee";
},
},
};
29 changes: 22 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
arg,
makeSchema,
} from "@nexus/schema";
import * as allTypes from "./schema";
import { ApolloServer } from "apollo-server";
import resolvers from "./graphql/resolvers";

const Node = interfaceType({
name: "Node",
Expand Down Expand Up @@ -53,10 +54,24 @@ const Query = queryType({
// Recursively traverses the value passed to types looking for
// any valid Nexus or graphql-js objects to add to the schema,
// so you can be pretty flexible with how you import types here.
const schema = makeSchema({
types: allTypes,
outputs: {},
// types: [Account, Node, Query, StatusEnum],
// or types: { Account, Node, Query }
// or types: [Account, [Node], { Query }]
// const schema = makeSchema({
// types: resolvers,
// outputs: {},
// types: [Account, Node, Query, StatusEnum],
// or types: { Account, Node, Query }
// or types: [Account, [Node], { Query }]
// });

const server = new ApolloServer({
typeDefs: `
type Query {
dahee: String!
}
`,
resolvers,
context: () => {
return { some: 1 };
},
});

server.listen().then(() => console.log("🚀 Apollo Server On!"));

0 comments on commit f0910da

Please sign in to comment.