Skip to content

Commit

Permalink
Remove _buildQueryHelper and _executeOperation (#3173)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Jul 3, 2020
1 parent 5fc97cb commit 8480f88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 68 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-stingrays-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/keystone': patch
---

Removed `keystone._buildQueryHelper()` and `keystone._executeOperation()`.
69 changes: 1 addition & 68 deletions packages/keystone/lib/Keystone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const flattenDeep = require('lodash.flattendeep');
const memoize = require('micro-memoize');
const falsey = require('falsey');
const createCorsMiddleware = require('cors');
const { graphql, execute, print } = require('graphql');
const { execute, print } = require('graphql');
const {
resolveAllKeys,
arrayToObject,
Expand Down Expand Up @@ -102,27 +102,6 @@ module.exports = class Keystone {
}
}

_executeOperation({
requestString,
rootValue = null,
contextValue,
variableValues,
operationName,
}) {
// This method is a thin wrapper around the graphql() function which uses
// contextValue.schemaName to select a schema created by app-graphql to execute.
// https://graphql.org/graphql-js/graphql/#graphql
const schema = this._schemas[contextValue.schemaName];
if (!schema) {
return Promise.reject(
new Error(
`No executable schema named '${contextValue.schemaName}' is available. Have you setup '@keystonejs/app-graphql'?`
)
);
}
return graphql(schema, requestString, rootValue, contextValue, variableValues, operationName);
}

_getAccessControlContext({ schemaName, authentication, skipAccessControl }) {
if (skipAccessControl) {
return {
Expand Down Expand Up @@ -269,52 +248,6 @@ module.exports = class Keystone {
};
}

/**
* A factory for generating executable graphql query functions.
*
* @param context Object The graphQL Context object
* @param context.schemaName String Usually 'admin', this is the registered
* schema as passed to keystone.registerSchema()
*
* @return Function An executable function for running a query
*/
_buildQueryHelper(defaultContext) {
/**
* An executable function for running a query
*
* @param requestString String A graphQL query string
* @param options.skipAccessControl Boolean By default access control _of
* the user making the initial request_ is still tested. Disable all
* Access Control checks with this flag
* @param options.variables Object The variables passed to the graphql
* query for the given queryString.
* @param options.context Object Overrides to the default context used when
* making a query. Useful for setting the `schemaName` for example.
*
* @return Promise<Object> The graphql query response
*/
return (
requestString,
{ skipAccessControl = false, variables, context = {}, operationName } = {}
) => {
let contextValue = { ...defaultContext, ...context };

if (skipAccessControl) {
contextValue.getCustomAccessControlForUser = () => true;
contextValue.getListAccessControlForUser = () => true;
contextValue.getFieldAccessControlForUser = () => true;
contextValue.getAuthAccessControlForUser = () => true;
}

return this._executeOperation({
contextValue,
requestString,
variableValues: variables,
operationName,
});
};
}

createAuthStrategy(options) {
const { type: StrategyType, list: listKey, config } = options;
const { authType } = StrategyType;
Expand Down

0 comments on commit 8480f88

Please sign in to comment.