Skip to content

Instantly share code, notes, and snippets.

@tkdn
Last active June 25, 2020 13:43
Show Gist options
  • Save tkdn/68b2dfcf1e9a4c21d7972a9ac1cdbbc8 to your computer and use it in GitHub Desktop.
Save tkdn/68b2dfcf1e9a4c21d7972a9ac1cdbbc8 to your computer and use it in GitHub Desktop.
会って 3 秒で Apollo Server
const startServer = async () => {
const app = express();
const server = new ApolloServer({
typeDefs: gql`
type Task {
id: ID!
priority: Int!
}
type Query {
task: [Task!]!
}
`,
resolvers: {
Query: {
async tasks(){
const db = mysql(config.mysql);
return await db.select("*").from("tasks");
}
}
}
});
server.applyMiddleware({ app });
app.listen({ port: 4000 }, () => console.log("🚀 Server ready"));
};
startServer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment