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

Compress GraphQL query string

flutter-ci

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

final compressedQuery = compressGraphqlQuery(query);

see example for input and output sample

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

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

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

Same deal with DioLink:

final link = DioLink(
  _apiUrl,
  client: Dio(),
  useGETForQueries: true,
  serializer: const RequestSerializerWithCompressor(),
);

⚠️ This is still an experimental version. Use it carefully. Suggestions or contributions are appreciated

7
likes
0
pub points
49%
popularity

Publisher

unverified uploader

Compress GraphQL query string

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

gql_exec, gql_link

More

Packages that depend on graphql_query_compress