gql
1.0.1, released a year ago by gql-dart.dev
Parse, transform and print GraphQL documents in Dart.
WASM-readyQuiet but busy
What it does
Provides libraries to parse GraphQL strings into an AST, visit and transform the AST, and print it back to a string. Includes experimental schema and operation helpers.
AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to work with GraphQL query documents at build‑time or runtime without a full client
- You want to generate or modify GraphQL queries programmatically
Skip it when
- You need a complete GraphQL client with networking and caching
- You require code‑generation of Dart models from GraphQL schemas
Strengths
- Lightweight and pure‑Dart
- Supports parsing, visiting, transforming and printing of GraphQL AST
- Works on all Dart platforms
Weaknesses
- No networking or execution layer
- Experimental schema/operation APIs may change
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:gql/language.dart' as lang;
import 'package:gql/ast.dart' as ast;
void main() {
final ast.DocumentNode doc = lang.parseString('''
query UserInfo($id: ID!) {
user(id: $id) { id name }
}
''');
print(lang.printNode(doc));
}Alternatives
Packages that do the same job and could replace gql.
Works with
Packages commonly used together with gql: ones it builds on, ones built on it, and its own family.
- yamlgql depends on itA Dart library for parsing YAML documents into Dart data structures.
- source_spangql depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- gql_http_linkBuilt on gqlHTTP link for executing GraphQL requests via JSON.
- normalizeBuilt on gqlNormalizes and denormalizes GraphQL responses to a cache-friendly map structure.
- gql_linkBuilt on gqlModular AST-based GraphQL request execution interface.
- graphqlBuilt on gqlA Dart GraphQL client offering queries, mutations, subscriptions and cache management.
- gql_code_builderBuilt on gqlDart code builder generating typed classes from GraphQL documents and SDL
- graphql_codegenBuilt on gqlGenerate Dart serializers and client helpers from GraphQL queries and schemas.