2022. 3. 7. 02:57ㆍ서버 프로그래밍
1. 가장 도움이 되는 예제
https://jason9319.tistory.com/411
Express와 Apollo server를 이용한 GraphQL API 만들기
지난번에 [Express.js/Node.js] Express framework를 이용한 REST API 서버 만들기 에서 Express 프레임워크를 이용하여 REST API서버를 만들어 보았다. 이번에는 Express 프레임워크와 Apollo Server를 이용해서..
jason9319.tistory.com
2. async, await를 이용한 start 함수 작성 및 실행
async function startApolloServer(typeDefs, resolvers){
const server = new ApolloServer({typeDefs, resolvers})
const app = express();
await server.start();
server.applyMiddleware({app, path: '/graphql'});
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}${server.graphqlPath}`);
})
}
startApolloServer(typeDefs, resolvers);
UnhandledPromiseRejectionWarning: Error: You must `await server.start()` before calling `server.applyMiddleware()` at ApolloServ
I am trying to start my nestJs server and It keeps giving me this error: UnhandledPromiseRejectionWarning: Error: You must await server.start() before calling server.applyMiddleware() at ApolloServ...
stackoverflow.com
3. Playground 변경 (Apollo Studio는 HTTPS만 동작 가능하기 때문)
function server() {
const serverApollo = new ApolloServer({
typeDefs: typeDefs,
resolvers: resolvers,
plugins: [ApolloServerPluginLandingPageGraphQLPlayground()] // this is the most important thing
})
serverApollo.listen().then(({ url }) => {
console.log(`Playground on: ${url}`)
})
}
https://github.com/apollographql/apollo-server/issues/5341
Bring back playground, no sandbox · Issue #5341 · apollographql/apollo-server
I don't understand why we should use a tool hosted on your servers. I'd like to have back playground or any solution that can run on my server or on my local setup. I don't want my data...
github.com
<기타 참고 자료>
https://www.apollographql.com/docs/apollo-server/integrations/middleware/#apollo-server-express
https://koonsland.tistory.com/148
[GraphQL] Apollo Server를 이용한 GraphQL 사용 방법
Apollo Server는 Server 프로그래밍과 Client 프로그래밍 모두에 사용할 수 있는 오픈 소스 GraphQL 서버입니다. 이번 포스팅에서는 Apollo Server와 GraphQL의 간단한 소개와 사용 방법에 대해서 알아보도록 하
koonsland.tistory.com
https://www.daleseo.com/graphql-apollo-server/
Apollo Server를 이용한 초간단 GraphQL 서버 개발
Engineering Blog by Dale Seo
www.daleseo.com