Skip to content

Commit

Permalink
Use keystone.executeGraphQL in singleton plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Jun 16, 2020
1 parent d3895eb commit 8bd5843
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-toes-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/list-plugins': patch
---

Updated to use `context.executeGraphQL` for all server-side GraphQL operations.
7 changes: 5 additions & 2 deletions packages/list-plugins/lib/limiting/singleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ exports.singleton = () => (
{ hooks = {}, access = {}, adminConfig = {}, ...rest },
{ listKey, keystone }
) => {
const newResolveInput = async ({ resolvedData, operation }) => {
const newResolveInput = async ({ context, resolvedData, operation }) => {
if (operation === 'create') {
const list = keystone.getListByKey(listKey);
const query = `{${list.gqlNames.listQueryMetaName} { count }}`;
const {
data: { [list.gqlNames.listQueryMetaName]: listQuery } = {},
errors,
} = await keystone.executeQuery(query);
} = await context.executeGraphQL({
context: context.createContext({ skipAccessControl: true }),
query,
});
if (errors) {
throw errors;
}
Expand Down

0 comments on commit 8bd5843

Please sign in to comment.