-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RAV] Remove persisted query link #1512
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
import 'cross-fetch/polyfill'; | ||
import { ApolloClient, InMemoryCache } from '@apollo/client'; | ||
import { sha256 } from 'js-sha256'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
|
||
/* eslint-disable import/order */ | ||
|
||
|
@@ -28,28 +27,22 @@ import introspectionQueryResultData from '../temp/GraphQLFragmentTypes.json'; | |
// ...or a batched link (multiple queries within 10ms all go in one HTTP request) | ||
import { BatchHttpLink } from '@apollo/client/link/batch-http'; | ||
|
||
// ...and an automatic persisted query link, which reduces bandwidth by using query hashes to alias content | ||
// the APQ link is _chained_ behind another link that performs the actual HTTP calls, so you can choose | ||
// APQ + batched, or APQ + http links for example. | ||
import { createPersistedQueryLink } from '@apollo/client/link/persisted-queries'; | ||
kendoce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import config from '../temp/config'; | ||
|
||
export default function (endpoint, ssr, initialCacheState) { | ||
export default function(endpoint, ssr, initialCacheState) { | ||
/* HTTP link selection: default to batched + APQ */ | ||
const link = createPersistedQueryLink({ sha256 }).concat( | ||
new BatchHttpLink({ | ||
uri: endpoint, | ||
headers: { | ||
connection: 'keep-alive', | ||
sc_apikey: config.sitecoreApiKey, | ||
}, | ||
}) | ||
); | ||
const link = new BatchHttpLink({ | ||
uri: endpoint, | ||
headers: { | ||
connection: 'keep-alive', | ||
sc_apikey: config.sitecoreApiKey, | ||
}, | ||
}); | ||
|
||
const possibleTypes = {}; | ||
|
||
introspectionQueryResultData.__schema.types.forEach((supertype) => { | ||
possibleTypes[supertype.name] = supertype.possibleTypes.map((subtype) => subtype.name); | ||
introspectionQueryResultData.__schema.types.forEach(supertype => { | ||
possibleTypes[supertype.name] = supertype.possibleTypes.map(subtype => subtype.name); | ||
}); | ||
|
||
const cache = new InMemoryCache({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import 'cross-fetch/polyfill'; // Apollo uses `fetch`, which needs a polyfill for node and older browsers. | ||
import { InMemoryCache, ApolloClient } from '@apollo/client/core'; | ||
import { sha256 } from 'js-sha256'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
|
||
/* | ||
INTROSPECTION DATA | ||
|
@@ -18,27 +17,23 @@ import introspectionQueryResultData from '../temp/GraphQLFragmentTypes.json'; | |
*/ | ||
|
||
// choose between a basic HTTP link to run queries... | ||
// import { createHttpLink } from 'apollo-link-http'; | ||
// const link = createHttpLink({ uri: endpoint }); | ||
|
||
// ...or a batched link (multiple queries within 10ms all go in one HTTP request) | ||
import { BatchHttpLink } from '@apollo/client/link/batch-http'; | ||
|
||
// ...and an automatic persisted query link, which reduces bandwidth by using query hashes to alias content | ||
// the APQ link is _chained_ behind another link that performs the actual HTTP calls, so you can choose | ||
// APQ + batched, or APQ + http links for example. | ||
import { createPersistedQueryLink } from '@apollo/client/link/persisted-queries'; | ||
kendoce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import config from '../temp/config'; | ||
|
||
export default function (endpoint, ssr, initialCacheState) { | ||
export default function(endpoint, ssr, initialCacheState) { | ||
/* HTTP link selection: default to batched + APQ */ | ||
const link = createPersistedQueryLink({ sha256 }).concat( | ||
new BatchHttpLink({ | ||
uri: endpoint, | ||
headers: { | ||
connection: 'keep-alive', | ||
sc_apikey: config.sitecoreApiKey, | ||
}, | ||
}) | ||
); | ||
const link = new BatchHttpLink({ | ||
uri: endpoint, | ||
headers: { | ||
connection: 'keep-alive', | ||
sc_apikey: config.sitecoreApiKey, | ||
}, | ||
}); | ||
|
||
const possibleTypes = {}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
apollo-angular/persisted-queries
andsha256
dependencies from package.json?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
sha56
butpersisted-queries
is a submodule ofapollo-angular
which is the primary dependency for apollo.