-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfaust.config.js
More file actions
40 lines (37 loc) · 930 Bytes
/
faust.config.js
File metadata and controls
40 lines (37 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { relayStylePagination } from "@apollo/client/utilities";
import { setConfig } from "@faustwp/core";
import possibleTypes from "./possibleTypes.json";
import templates from "./src/wp-templates";
class PostTypePolicyPlugin {
apply({ addFilter }) {
addFilter(
"apolloClientInMemoryCacheOptions",
"faust",
(inMemoryCacheObject) => {
// Merge existing Faust typePolicies with with relayStylePagination for Posts
const existingPolicies = inMemoryCacheObject.typePolicies || {};
return {
...inMemoryCacheObject,
typePolicies: {
...existingPolicies,
Query: {
...existingPolicies.Query,
fields: {
posts: relayStylePagination(),
},
},
},
};
},
);
}
}
/**
* @type {import('@faustwp/core').FaustConfig}
*/
export default setConfig({
templates,
plugins: [new PostTypePolicyPlugin()],
possibleTypes,
usePersistedQueries: true,
});