gajus / gajus/graphql-deduplicator

Standard HTTP header to ask for deduplicated data

Open
#5 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
279
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Instead of recommending to use a query param, why don't we recommend using a custom HTTP header to request deduplicated data?

- `inflate` is a noop if the data wasn't deflated it doesn't matter whether the backend ends up sending deduplicated data or not
- Headers aren't visible in the URL which is neater
- Backend usage is the ~same

I imagine something like this:

```JS
const httpLink = new HttpLink({
credentials: 'include',
uri: '/api',
headers: {
'X-GraphQL-Deduplicate': true
}
});
```

```JS
app.use('/graphql', graphqlExpress((request) => {
return {
formatResponse: (response) => {
if (request.headers['X-GraphQL-Deduplicate'] && response.data && !response.data.__schema) {
return deflate(response.data);
}

return response;
}
};
}));
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the existing recommendation for using a query parameter and the request/response handling shown in the issue. Compare that approach with the proposed X-GraphQL-Deduplicate header, then define the agreed client and server behavior and verify that deduplication occurs only when the header is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.