retrofit_graphql 2.1.2 copy "retrofit_graphql: ^2.1.2" to clipboard
retrofit_graphql: ^2.1.2 copied to clipboard

retrofit_graphql or Retrofit GraphQL for Dart is a powerful code generation tool that simplifies working with GraphQL in Dart projects. This tool automates the generation of Dart classes for types, en [...]

example/lib/main.dart

import 'package:retrofit_graphql_example/generated/client.gq.dart';
import 'package:http/http.dart' as http;

void main(List<String> args) {
  const wsUrl = "ws://localhost:8080/graphql";
  const url = "http://localhost:8080/graphql";
  var wsAdapter = WebSocketChannelAdapter(wsUrl);

  fn(payload) => http
      .post(Uri.parse(url), body: payload, headers: {"Content-Type": "application/json"})
      .asStream()
      .map((response) => response.body)
      .first;

  var client = GQClient(fn, wsAdapter);

  client.queries
      .getUser(id: "test", client: true)
      .asStream()
      .map((event) => event.getUser)
      .first
      .then((value) {
    // print("isDriver => ${value is Client}");
    // print("go response = ${value.runtimeType}");
  });

  client.queries
      .getUser(id: "test", client: false)
      .asStream()
      .map((event) => event.getUser)
      .first
      .then((value) {
    //  print("isDriver => ${value is Driver}");
    //  print("go response = ${value.runtimeType}");
  });
}
2
likes
0
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

retrofit_graphql or Retrofit GraphQL for Dart is a powerful code generation tool that simplifies working with GraphQL in Dart projects. This tool automates the generation of Dart classes for types, enums, inputs. Additionally, it creates a GraphQL client for streamlined query, mutation and subscription execution. The code generator can also be configured to generate fragments that simplify attribute access.​

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

build, glob, logger, petitparser, source_gen

More

Packages that depend on retrofit_graphql