gql_code_builder는 GraphQL 스키마 정의(SDL) 및 쿼리 문서를 타입 안전한 Dart 클래스로 변환하는 Dart 코드 생성 패키지입니다. 개발자들이 .graphql 파일에서 모델, 쿼리, 변경, 변수를 직접 생성할 수 있게 해주며, 코드 유지보수성을 향상시키고 반복 코드를 줄여줍니다. build_runner의 강력한 기능을 활용하여 Flutter 및 Dart 프로젝트에 원활하게 통합되며, GraphQL 작업에 대해 강타입과 컴파일 시 안정성을 보장합니다. 생성된 코드는 최소한의 수동 작업으로 클라이언트 측 및 서버 측 사용 사례 모두를 지원합니다.
사용 사례
타입 안전한 GraphQL 쿼리 생성
SDL에서 모델 생성 자동화
GraphQL 클라이언트에서 반복 코드 줄이기
쿼리의 컴파일 시 검증 활성화
build_runner 워크플로우와의 통합
주요 기능
.graphql 파일에서 Dart 클래스 생성
SDL 및 쿼리 문서 분석을 지원합니다
형 안전한 모델과 작업을 생성합니다
build_runner와 통합
확장 가능한 코드 생성 훅 제공
적합한 대상
GraphQL를 사용하는 Flutter 앱
강한 타입 지정이 필요한 Dart 프로젝트
코드 품질과 유지보수성을 우선시하는 팀
자동 코드 생성이 필요한 GraphQL 클라이언트
gql-dart 생태계를 사용하는 프로젝트
고려 사항
빌드 러너 설정이 필요합니다
정적 스키마 분석에 제한됨
빌드 시간이 증가할 수 있습니다
런타임 스키마 변경에 적합하지 않습니다
소스 파일 내 올바른 GraphQL 구문에 따라 다름
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
gql-dart/gql
This is an effort to advance the Dart GraphQL ecosystem.
It consists of multiple packages and libraries centered around GraphQL AST.
Core
The core of this project is the GraphQL parser which parses GraphQL strings into an AST. The parsed AST can then be transformed, visited and printed back to GraphQL string.
To enable development of GraphQL clients, we provide type definitions used to execute GraphQL operations. They include AST-based operation, request with per operation context, and response. These types are used by the Links.
Link is the current client implementation. Link is GraphQL AST-aware request/response middleware. They can be used to build a pipeline to deduplicate requests, conditionally transform requests and responses (including the context), and eventually send the requests to the server.
The goal of this project is to expand Dart GraphQL ecosystem
and to build a community around this vendor-neutral implementation.
Community contributions are welcome.
Release Process
This repository uses Melos to manage the monorepo and handle releases. The release process is partially automated through GitHub Actions.
Repository Structure
The repository is organized into several package categories:
Core packages:
gql: Core GraphQL package
gql_tristate_value
gql_code_builder_serializers
gql_code_builder
Execution packages:
gql_exec
gql_link
Link implementations:
gql_http_link
gql_dio_link
gql_websocket_link
gql_dedupe_link
gql_error_link
gql_transform_link
Build packages:
gql_build
Local Development
To get started with local development:
Install Melos:
dart pub global activate melos && dart pub get
Bootstrap the workspace:
melos bootstrap
Run tests:
melos test
Release Process
Automated Publishing
The publish workflow is automated via GitHub Actions and triggers when:
Changes are pushed to the master or release branches AND include changes to any pubspec.yaml file
Manually triggered through GitHub Actions UI
The automated process:
Validates all packages (formatting, analysis, and tests)
Publishes packages in dependency order:
Core packages first
Execution packages second
Link implementation packages third
Build packages last
Manual Release Steps
To create a new release manually:
Ensure you're on the branch you want to release from (master or release)
Version the packages using one of the following commands:
# For a patch release
melos run bump-patch
# For a minor release
melos run bump-minor
# For a major release
melos run bump-major
# For an alpha release
melos run bump-alpha
# To graduate from prerelease(alpha) to stable
melos run graduate
Push the changes and tags:
git push && git push --tags
The GitHub Action will automatically handle publishing to pub.dev if changes include pubspec.yaml files
Versioning Rules
Use bump-patch for backward-compatible bug fixes
Use bump-minor for backward-compatible features
Use bump-major for breaking changes
Use bump-alpha for prerelease versions
Use graduate to promote prerelease versions to stable
Available Melos Commands
melos bootstrap: Set up the workspace
melos clean: Clean all packages
melos test: Run tests for all packages
melos format: Format all packages
melos analyze: Run static analysis
melos build: Run build_runner for all packages
melos publish: Publish packages to pub.dev
Troubleshooting
If the automated publish fails:
Check the GitHub Actions logs for specific errors
Ensure all tests are passing locally: melos test
Verify that version numbers in pubspec.yaml files are correct
Check that all dependencies are properly versioned
For manual publishing (if needed, requires pub dev authentication):