gqlify 0.1.0
gqlify: ^0.1.0 copied to clipboard
GraphQL, simplified for Dart. A build-time GraphQL code generator producing small, strongly typed Dart APIs from a schema and operation documents.
gqlify example #
A complete, runnable example lives in the repository's
example/
package. In short:
# pubspec.yaml
dependencies:
gqlify_runtime: ^0.1.0
dev_dependencies:
gqlify: ^0.1.0
gqlify:
schema: lib/graphql/schema.graphql
# lib/graphql/products.graphql
query GetProduct($sku: ID!) {
product(sku: $sku) { sku name price }
}
dart run gqlify generate # or: dart run build_runner build
import 'package:gqlify_runtime/gqlify_runtime.dart';
import 'graphql/schema.graphql.dart';
import 'graphql/products.graphql.dart';
Future<void> main() async {
final api = GqlifyClient(
transport: HttpTransport(Uri.parse('https://shop.example/graphql')),
);
final data = await api.getProduct(sku: 'ABC123');
print(data.product?.name);
}
