Comments (1)
It worked for me following the instructions. Sounds like the HTTP linker is running before cruncher. Be sure that cruncher comes first in the linking concat
method.
For example:
new ApolloClient({
ssrMode: options.ssr === true,
link: concat(uncruncher, httpLink),
cache: new InMemoryCache({}),
});
Here a simplified example of my implementation:
Server
import { ApolloServer } from 'apollo-server-express';
import { crunch } from 'graphql-crunch';
import { schema } from './schema';
export const createGraphQLServer = () => {
return new ApolloServer({
schema,
formatResponse: (response) => {
response.data = crunch(response.data, 2);
return response;
},
});
}
Client
import { ApolloClient, InMemoryCache, ApolloLink, HttpLink, concat } from '@apollo/client';
import { uncrunch } from 'graphql-crunch';
export function apolloClient(options) {
// Crunch compression expander
const uncruncher = new ApolloLink((operation, forward) =>
forward(operation).map((response) => {
const { data } = response;
if (typeof data['crunched'] !== 'undefined') {
response.data = uncrunch(data);
}
return response;
})
);
const httpLink = new HttpLink({
uri: `http://localhost:3000/graphql`,
});
return new ApolloClient({
link: concat(uncruncher, httpLink),
cache: new InMemoryCache({}),
});
}
from graphql-crunch.
Related Issues (17)
- Further Crunching On Key Level HOT 8
- Add TypeScript definitions HOT 2
- Hi i am facing problem in apolloclient config HOT 4
- Wrong response if response in date string
- What is the reason for creating graphql-crunch when graphql-deduplicator is available? HOT 1
- Not compiled to es5 HOT 1
- Dynamic require defined at line 5; not supported by Metro HOT 2
- [Feature-Request][How-To] Use with Apollo-Server-Express
- Explanation of the v2 `encode` function HOT 1
- Unexpected efficiency results with crunching HOT 1
- Any plans to provide TypeScript declarations? HOT 2
- [Question] Can this be used in normal JSON minify, like Restful json response? HOT 1
- formatResponse(response, options) field options.context.request is undefined HOT 1
- Publish new version (2.1.4) with Typescript types to npm and create a new release
- Integrate directly into resolvers
- Integrate a chrome extension for previews
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-crunch.