mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-23 14:39:32 +08:00
feat(graphql): All user object to request operators parser.
This commit is contained in:
parent
6238c6f6ba
commit
9e43b27a47
@ -39,7 +39,6 @@ function createContext(config) {
|
||||
bootstrapContext.getLoader = createGetLoader(bootstrapContext);
|
||||
bootstrapContext.getController = createGetController(bootstrapContext);
|
||||
bootstrapContext.user = await verifyAccessToken(bootstrapContext);
|
||||
console.log(bootstrapContext.user);
|
||||
return {
|
||||
getController: bootstrapContext.getController,
|
||||
logger,
|
||||
|
@ -21,10 +21,11 @@ import { ConfigurationError, RequestError } from '../context/errors';
|
||||
import resolvers from '../connections/resolvers';
|
||||
|
||||
class RequestController {
|
||||
constructor({ getLoader, getSecrets }) {
|
||||
constructor({ getLoader, getSecrets, user }) {
|
||||
this.getSecrets = getSecrets;
|
||||
this.requestLoader = getLoader('request');
|
||||
this.connectionLoader = getLoader('connection');
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
async callRequest(requestInput) {
|
||||
@ -150,6 +151,7 @@ class RequestController {
|
||||
secrets,
|
||||
state,
|
||||
urlQuery,
|
||||
user: this.user,
|
||||
});
|
||||
|
||||
const { output: connectionProperties, errors: connectionErrors } = operatorsParser.parse({
|
||||
|
@ -76,7 +76,7 @@ const loaders = {
|
||||
},
|
||||
};
|
||||
|
||||
const context = testBootstrapContext({ loaders, getSecrets });
|
||||
const context = testBootstrapContext({ loaders, getSecrets, user: { name: 'name' } });
|
||||
|
||||
const defaultInput = {
|
||||
arrayIndices: [],
|
||||
@ -330,6 +330,7 @@ test('parse request properties for operators', async () => {
|
||||
state: { _state: 'value' },
|
||||
urlQuery: { _url_query: 'value' },
|
||||
arrayIndices: { _state: 'array.$' },
|
||||
user: { _user: 'name' },
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -372,6 +373,7 @@ test('parse request properties for operators', async () => {
|
||||
state: 'stateValue',
|
||||
urlQuery: 'urlValue',
|
||||
arrayIndices: 'one',
|
||||
user: 'name',
|
||||
},
|
||||
},
|
||||
success: true,
|
||||
@ -393,6 +395,7 @@ test('parse connection properties for operators', async () => {
|
||||
state: { _state: 'value' },
|
||||
urlQuery: { _url_query: 'value' },
|
||||
arrayIndices: { _state: 'array.$' },
|
||||
user: { _user: 'name' },
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -433,6 +436,7 @@ test('parse connection properties for operators', async () => {
|
||||
state: 'stateValue',
|
||||
urlQuery: 'urlValue',
|
||||
arrayIndices: 'one',
|
||||
user: 'name',
|
||||
},
|
||||
request: {
|
||||
requestProperty: 'requestProperty',
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import createGetController from '../controllers/getController';
|
||||
|
||||
function testBootstrapContext({ development, getSecrets, host, loaders, setHeaders } = {}) {
|
||||
function testBootstrapContext({ development, getSecrets, host, loaders, setHeaders, user } = {}) {
|
||||
const bootstrapContext = {
|
||||
CONFIGURATION_BASE_PATH: 'CONFIGURATION_BASE_PATH',
|
||||
development,
|
||||
@ -26,12 +26,13 @@ function testBootstrapContext({ development, getSecrets, host, loaders, setHeade
|
||||
host: host || 'host',
|
||||
logger: { log: () => {} },
|
||||
setHeaders: setHeaders || [],
|
||||
user: user || {},
|
||||
};
|
||||
bootstrapContext.getController = createGetController(bootstrapContext);
|
||||
return bootstrapContext;
|
||||
}
|
||||
|
||||
function testContext({ development, getSecrets, host, loaders, setHeaders } = {}) {
|
||||
function testContext({ development, getSecrets, host, loaders, setHeaders, user } = {}) {
|
||||
const bootstrapContext = {
|
||||
development,
|
||||
getLoader: (name) => loaders[name],
|
||||
@ -39,6 +40,7 @@ function testContext({ development, getSecrets, host, loaders, setHeaders } = {}
|
||||
host: host || 'host',
|
||||
logger: { log: () => {} },
|
||||
setHeaders: setHeaders || [],
|
||||
user: user || {},
|
||||
};
|
||||
bootstrapContext.getController = createGetController(bootstrapContext);
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user