schema는 SDL(Schema Definition Language)로 작성된, GraphQL API의 타입이 정의된 계약입니다. 모든 타입, 모든 필드, 그리고 특별한 root 타입 — Query(읽기), Mutation(쓰기), 그리고 선택적으로 Subscription(실시간) — 을 선언합니다. 서버는 schema에 맞지 않는 요청은 모두 거부합니다.
schema는 SDL(Schema Definition Language)로 작성된, GraphQL API의 타입이 정의된 계약입니다. 모든 타입, 모든 필드, 그리고 특별한 root 타입 — Query(읽기), Mutation(쓰기), 그리고 선택적으로 Subscription(실시간) — 을 선언합니다. 서버는 schema에 맞지 않는 요청은 모두 거부합니다.
Int, Float, String, Boolean, ID가 있습니다. DateTime 같은 custom scalar를 정의할 수도 있습니다.scalar DateTime # a custom scalar
type User { # an object type
id: ID! # ! means non-null (always present)
name: String!
createdAt: DateTime!
posts: [Post!]! # a list of Post objects, non-null list of non-null items
}
type Post {
id: ID!
title: String!
author: User! # points back to User -> a relationship
}
type Query { # root type: the entry points for reads
user(id: ID!): User # a field with an argument; returns a User (nullable)
}
!는 non-null을 표시합니다; [Post!]!는 항목이 non-null인 non-null 리스트입니다. 인자(id: ID!)는 필드를 파라미터화할 수 있게 합니다.
schema는 단일 진실 공급원(single source of truth)입니다 — 검증, 자동 생성 문서, 클라이언트 codegen을 구동합니다. !와 리스트 타입을 정확히 읽는 것은 흔한 junior 선별 확인 사항이며, nullability 결정은 클라이언트가 오류를 처리하는 방식을 좌우합니다.
주니어부터 시니어까지 상세한 답변이 포함된 IT 면접 질문 라이브러리.
후원하기