graphql_query_compress 1.0.0 copy "graphql_query_compress: ^1.0.0" to clipboard
graphql_query_compress: ^1.0.0 copied to clipboard

A package that eliminates unnecessary characters from a GraphQL query, saving several bytes on requests.

flutter-ci

This package eliminates unnecessary characters from a GraphQL query, saving several bytes on requests.

final compressedQuery = compressGraphqlQuery(query);

GQL will serialize your query in a human-readable format after parse it to DocumentNodes. Therefore, we can't simple compress it before using the GQL parser.

To overcome this, we need to replace GQL RequestSerializer by RequestSerializerWithCompressor

return GraphQLClient(
  cache: GraphQLCache(store: null),
  link: HttpLink(
    _apiUrl,
    serializer: const RequestSerializerWithCompressor(),
  ),
);

The same applies to DioLink:

final link = DioLink(
  _apiUrl,
  client: Dio(),
  useGETForQueries: true,
  serializer: const RequestSerializerWithCompressor(),
);
7
likes
160
pub points
49%
popularity

Publisher

unverified uploader

A package that eliminates unnecessary characters from a GraphQL query, saving several bytes on requests.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

gql_exec, gql_link

More

Packages that depend on graphql_query_compress