From f7e8fb38956376d31f5ffece23ece14afd98c451 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Tue, 17 Oct 2023 14:41:13 -0400 Subject: [PATCH] Outdated plugins - faust now handles things Signed-off-by: Joe Fusco --- faust.config.js | 7 +- plugins/PersistedQueriesPlugin.js | 27 ------- plugins/TempPersistedQueriesFixPlugin.js | 92 ------------------------ 3 files changed, 1 insertion(+), 125 deletions(-) delete mode 100644 plugins/PersistedQueriesPlugin.js delete mode 100644 plugins/TempPersistedQueriesFixPlugin.js diff --git a/faust.config.js b/faust.config.js index 0280a15..22514ad 100644 --- a/faust.config.js +++ b/faust.config.js @@ -1,18 +1,13 @@ import { setConfig } from '@faustwp/core' import templates from '@/wp-templates/index.js' import possibleTypes from './possibleTypes.json' -import PersistedQueriesPlugin from './plugins/PersistedQueriesPlugin' -import TempPersistedQueriesFixPlugin from './plugins/TempPersistedQueriesFixPlugin' /** * @type {import('@faustwp/core').FaustConfig} **/ export default setConfig({ templates, - experimentalPlugins: [ - // new TempPersistedQueriesFixPlugin(), - // new PersistedQueriesPlugin(), - ], + experimentalPlugins: [], usePersistedQueries: true, possibleTypes, }) diff --git a/plugins/PersistedQueriesPlugin.js b/plugins/PersistedQueriesPlugin.js deleted file mode 100644 index ea862dd..0000000 --- a/plugins/PersistedQueriesPlugin.js +++ /dev/null @@ -1,27 +0,0 @@ -import { createPersistedQueryLink } from '@apollo/client/link/persisted-queries' -import { HttpLink } from '@apollo/client' -import { sha256 } from 'crypto-hash' -import { getGraphqlEndpoint } from '@faustwp/core/dist/mjs/lib/getGraphqlEndpoint' - -const httpLink = new HttpLink({ uri: getGraphqlEndpoint() }) -const persistedQueriesLink = createPersistedQueryLink({ - sha256, - useGETForHashedQueries: true, -}) - -class PersistedQueriesPlugin { - apply({ addFilter }) { - addFilter('apolloClientOptions', 'faust', (apolloClientOptions) => { - const existingLink = apolloClientOptions?.link - return { - ...apolloClientOptions, - link: - existingLink instanceof HttpLink - ? persistedQueriesLink.concat(existingLink) - : persistedQueriesLink.concat(httpLink), - } - }) - } -} - -export default PersistedQueriesPlugin diff --git a/plugins/TempPersistedQueriesFixPlugin.js b/plugins/TempPersistedQueriesFixPlugin.js deleted file mode 100644 index e3d6065..0000000 --- a/plugins/TempPersistedQueriesFixPlugin.js +++ /dev/null @@ -1,92 +0,0 @@ -import { gql } from '@apollo/client' - -class TempPersistedQueriesFixPlugin { - apply({ addFilter }) { - addFilter('seedQueryDocumentNode', 'faust', () => { - return gql` - query GetSeedNode( - $id: ID! = 0 - $uri: String! = "" - $asPreview: Boolean = false - ) { - ... on RootQuery @skip(if: $asPreview) { - nodeByUri(uri: $uri) { - __typename - ...GetNode - } - } - ... on RootQuery @include(if: $asPreview) { - contentNode(id: $id, idType: DATABASE_ID, asPreview: true) { - __typename - ...GetNode - } - } - } - - fragment GetNode on UniformResourceIdentifiable { - __typename - uri - id - ...DatabaseIdentifier - ...ContentType - ...User - ...TermNode - ...ContentNode - ...MediaItem - ...Page - } - - fragment DatabaseIdentifier on DatabaseIdentifier { - databaseId - } - - fragment MediaItem on MediaItem { - id - mimeType - } - - fragment ContentType on ContentType { - name - isFrontPage - - # This is currently broken. The home page (blog page) can not be - # resolved when set to a custom page until the below issue is resolved. - # Link: https://github.com/wp-graphql/wp-graphql/issues/2514 - isPostsPage - } - - fragment Page on Page { - isFrontPage - isPostsPage - } - - fragment TermNode on TermNode { - isTermNode - slug - taxonomyName - } - - fragment ContentNode on ContentNode { - isContentNode - slug - contentType { - node { - name - } - } - template { - templateName - } - } - - fragment User on User { - name - userId - databaseId - } - ` - }) - } -} - -export default TempPersistedQueriesFixPlugin