Skip to main content

gqlify_runtime 0.1.0 copy "gqlify_runtime: ^0.1.0" to clipboard
gqlify_runtime: ^0.1.0 copied to clipboard

Lightweight, pure-Dart runtime for code generated by gqlify: injectable transports, typed operation results and explicit GraphQL error semantics.

example/gqlify_runtime_example.dart

// The runtime is used by code generated by gqlify; this example shows the
// pieces applications touch directly: transports and responses.
import 'package:gqlify_runtime/gqlify_runtime.dart';
import 'package:gqlify_runtime/testing.dart';

/// A hand-written operation, equivalent to what gqlify generates.
final class HelloQuery extends GqlifyOperation<String> {
  const HelloQuery();

  @override
  String get operationName => 'Hello';

  @override
  GqlifyOperationType get operationType => GqlifyOperationType.query;

  @override
  String get document => 'query Hello { hello }';

  @override
  Map<String, Object?> get variables => const {};

  @override
  String parseData(Map<String, Object?> data) => data['hello']! as String;
}

final class Client extends GqlifyClientBase {
  Client({required super.transport});
}

Future<void> main() async {
  // Swap MockTransport for HttpTransport(Uri.parse('https://...')) in apps.
  final client = Client(
    transport: MockTransport.fixed({
      'data': {'hello': 'world'},
    }),
  );
  final response = await client.execute(const HelloQuery());
  print(response.dataOrThrow);
  await client.close();
}
0
likes
160
points
52
downloads
screenshot

Documentation

API reference

Publisher

verified publisherenver.dev

Weekly Downloads

Lightweight, pure-Dart runtime for code generated by gqlify: injectable transports, typed operation results and explicit GraphQL error semantics.

Repository (GitHub)
View/report issues

Topics

#graphql #http #api #client

License

MIT (license)

Dependencies

http

More

Packages that depend on gqlify_runtime