Node.js Express에서 GraphQL 구현

2022. 2. 7. 06:58서버 프로그래밍

1. PostgreSQL과 연동하는 GraphQL 구현

https://blog.harveydelaney.com/setting-up-graphql-express-and-postgresql/

 

Setting up GraphQL, Node/Express and PostgreSQL

An article showing you how to quickly get your back-end project started with GraphQL, Node/Express and PostgreSQL.

blog.harveydelaney.com

다 좋은데 오래된 예제라 다음 두가지 수정이 필요하다.

(1) inside your schema.js as you create Object Type for String as

 fields: {
              name: {type: String} 
    }

https://stackoverflow.com/questions/44980989/graphql-query-type-field-type-must-be-output-type-but-got-undefined

 

GraphQL: Query.type field type must be Output Type but got: undefined

I'm trying my first GraphQL approach. Here is the code: schema.js: import { GraphQLSchema, GraphQLObjectType, GraphQLInputObjectType, GraphQLNonNull, GraphQLString,

stackoverflow.com

(2) Please replace your expressGraphQL with graphqlHTTP as it was destructured

Use:

const { graphqlHTTP } = require('express-graphql');

or

const expressGraphQL = require('express-graphql').graphqlHTTP

https://stackoverflow.com/questions/65517979/expressgraphql-is-not-a-function

 

expressGraphQL is not a function

I am learning GraphQL for my project using this tutorial: https://www.youtube.com/watch?v=ZQL7tL2S0oQ&ab_channel=WebDevSimplified and I get the error: TypeError: expressGraphQL is not a functio...

stackoverflow.com

 

2. MongoDB와 연동하는 GraphQL 구현

https://dev.to/adityajoshi12/graphql-with-nodejs-and-mongodb-2bdm

 

GraphQL with NodeJs and MongoDB

What is GraphQL - A Query Language for APIs? GraphQL is a query language for your API, and a server-...

dev.to

 

기타

https://zinirun.github.io/2020/10/27/graphql-crud-sample/

 

Node.js - GraphQL로 CRUD 만들기 | zinirun

REST API VS GraphQL REST API로만 벡엔드 서버 API를 구현한 나로서는 굳이 GraphQL이란 것을 알아야할까 싶었다. 이 생각은 GraphQL로 간단한 프로젝트를 만들어 보며 완전히 바뀌게 되었다. 11분동안 정말

zinirun.github.io

https://buddy.works/tutorials/building-graphql-server-using-nodejs-and-express

 

Building a GraphQL Server using NodeJS and Express

Learn to build a GraphQL server for a food ordering system using NodeJS and Express.

buddy.works

https://blog.logrocket.com/creating-a-node-js-graphql-server-using-prisma-2/

 

Creating a Node.js GraphQL server using Prisma 2 - LogRocket Blog

We'll be building a basic polling GraphQL server. Some understanding of Prisma will make it easier to go along with this article.

blog.logrocket.com