next.js에서 apollo사용해서 spring에 API요청하기

Kyle_Kim·2023년 6월 25일
0

알아야 할 개념 첫번째

export function

먼저 data fetching에서 흔하지만 server-side-render에서 알아야 할 개념은 export function이다

The export function syntax is part of the Next.js API for defining page
components. When you create a page in Next.js, 
you typically create a JavaScript file inside the pages directory. 
This file contains a React component that represents the page.

필요한 클라이언트를 export default로 export해서 사용한다.

@apollo/client에서 import할 것들

import { ApolloClient, InMemoryCache, gql } from "@apollo/client";

- ApolloClient: 요청에 필요한 클라이언트

- InMemoryCache: 요청 된 데이터가 나중에 재사용 될 수 있도록 캐시화 시키는것.

- gql : String query를 파싱하여 쿼리를 날리는데 도움을 준다

TypeScript에서 Graphql조합이 좋은지 모르겠다는 평이 있다...

profile
Make Things Right

0개의 댓글