GRAPHQL / GENERATED CONSUMERS
검사는 통과했지만, 생성 타입은 예전 것이었다The checks passed. The generated types were stale.
GraphQL API에서 상품명이 null일 수 있도록 타입 정의를 바꿨습니다. 쿼리 검증과 기존 함수 컴파일은 모두 통과했지만, 컴파일에는 예전 정의로 만든 TypeScript 타입이 쓰였습니다.
The GraphQL API definition changed to allow a null product name. Query validation and compilation of the existing function both passed—but compilation still used TypeScript types generated from the old definition.
01두 검사에 들어간 입력The inputs behind two passing checks
스키마는 API가 반환할 값의 타입을 정합니다. 이 개인 실험은 가상 스키마와 쿼리에서 공식 GraphQL Code Generator(Codegen)로 만든 TypeScript 타입을 같은 예제 함수에 적용해 컴파일합니다. 쿼리에는 새 스키마를 쓰고, 컴파일에는 이전 타입을 남긴 대조군을 두었습니다.
A schema defines the API’s response types. This independent lab compiles fixed functions against TypeScript types produced from synthetic schemas and queries by official GraphQL Code Generator (Codegen). One control validates queries against the new schema but compiles the functions against old types.
두 쿼리는 여전히 유효했습니다. 그러나 스키마 비교에서는 name에 null을 허용한 변경을 기존 타입 보장을 약화하는 breaking 변경으로 분류했습니다. 이전 생성 타입의 name은 여전히 string이었습니다. 컴파일 성공은 새 계약을 처리한다는 근거가 아니었습니다.
Both queries remained valid, while schema comparison classified the weakened non-null guarantee for name as breaking. The old generated type still declared name as string. Passing compilation did not establish compatibility with the new contract.
쿼리 검증: 통과Query validation: pass
040ea438a171…후보 스키마 / name: StringCandidate schema / name: String상품명 함수 컴파일: 통과Name function compilation: pass
5dac235c739c…타입을 만든 스키마 / name: String!Schema used for types / name: String!두 통과 결과를 묶기 전에, 같은 변경을 검사했는지 확인해야 합니다.Before combining two passing results, check that they cover the same change.
02재생성·정책·선택 필드를 따로 비교하기Separate freshness, policy and selected fields
상품명 함수의 return product.name.toUpperCase();는 그대로 두었습니다. 공식 Codegen으로 타입을 다시 만들자 실제 TypeScript 컴파일 결과가 달라졌습니다.
The name function kept the same return product.name.toUpperCase();. Regenerating its types with official Codegen changed the real TypeScript compilation result.
| 스키마 / 사용한 타입Schema / types used | 쿼리 검증Query validation | 상품명 함수 컴파일Name function compilation |
|---|---|---|
name: String!새로 생성Regenerated | 유효Valid | 성공Pass |
name: String새로 생성Regenerated | 유효Valid | TS18047 |
name: String이전 타입 재사용Stale baseline types | 유효Valid | 성공 — 변경 미반영Pass — change not covered |
strict-name.ts(6,10): error TS18047: 'product.name' is possibly 'null'.
타입 생성 옵션도 결과를 바꿨습니다. futureProofEnums: true는 enum 유니온에 "%future added value"를 추가합니다. 스키마를 바꾸지 않아도 빠뜨린 재고 상태를 assertNever로 확인하는 함수는 컴파일에 실패했고, 대체 문구를 반환하는 함수는 통과했습니다. 다만 컴파일 성공만으로 그 문구가 사용자에게 적절한지는 알 수 없습니다. 이 옵션은 실제 응답값을 변환하지 않습니다.
Generator options changed the result too. futureProofEnums: true adds "%future added value" to the enum union. Even without a schema change, the function using assertNever to check for unhandled states failed to compile; the fallback function passed. Passing compilation does not establish whether that fallback message is appropriate for users. This option does not transform response values at runtime.
반대로, 쿼리가 선택하지 않는 nullable 필드를 추가하면 스키마 해시가 달라져도 두 생성 타입 파일의 바이트는 같았습니다. 해시 차이는 입력 차이의 근거이지, 곧바로 breaking 판정은 아닙니다.
Adding an unselected nullable field changed the schema hash but left both generated type files byte-identical. A different hash establishes different input, not automatically a breaking change.
03직접 확인할 수 있는 근거Evidence you can inspect
전체 실행은 8개 조건, 실제 컴파일 28회이며, 이 글은 주요 대조군을 골라 설명합니다. 코드·쿼리·스키마는 개인 실험용입니다. 리졸버와 예제 함수는 실행하지 않았으며, 회사나 실서비스의 성과를 주장하지 않습니다.
The full run contains 8 cases and 28 actual compilations; this note presents selected controls. Code, queries and schemas are synthetic personal fixtures. Resolvers and consumer functions were not executed; these are not employer or production results.
전체 해시·도구·추가 대조군Full hashes, tools and other controls
- 소스 커밋Source revision
a63ef7b6a00e02d96c248fd3f06cd0db6c0d4aeb- Report SHA-256
454db54e059216006aec76c0ab35b4e75ee244a7b06824205d4d9018d1c0a39a- Generated from
5dac235c739cda409e68e44b5819743753870c8d222132bae321860580a67d3f- Candidate schema
040ea438a17142e42e1a949a2da51afdda3ae6e8ee32ab275d4fd2b33cc2872c- Fixed consumer
6ec69eeb88a957fd6a045251cb528f22c7ed5129c85b7a690c00e7a699837411- 도구 버전Tool versions
- Codegen core 6.2.2 · TypeScript operations 6.1.10 · TypeScript 7.0.2 · GraphQL 16.14.2
예제의 NonNullable은 제품이나 재고 정보 자체가 없는 경우를 호출부에서 처리한다고 전제합니다. 도구 실패나 예상 밖의 진단은 실험 실패로 처리합니다. 의도한 타입 오류를 관찰했을 때의 종료 코드 0은 배포 승인을 뜻하지 않습니다.
The fixtures use NonNullable, leaving absent product or availability handling to the caller. Tool failures and unexpected diagnostics fail the experiment. Exit 0 after observing deliberate type errors is not deployment approval.
공식 자료Primary references: GraphQL validation · Codegen API · Operation types · TypeScript exhaustiveness