Last active
June 25, 2020 13:43
-
-
Save tkdn/68b2dfcf1e9a4c21d7972a9ac1cdbbc8 to your computer and use it in GitHub Desktop.
会って 3 秒で Apollo Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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