mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-23 14:39:32 +08:00
feat(graphql): Rename args object to event.
This commit is contained in:
parent
a869441bf6
commit
e3bb6f50a6
@ -8,6 +8,6 @@ module.exports = {
|
||||
coverageReporters: [['lcov', { projectRoot: '../..' }], 'text', 'clover'],
|
||||
errorOnDeprecated: true,
|
||||
testEnvironment: 'node',
|
||||
preset: '@shelf/jest-mongodb',
|
||||
// preset: '@shelf/jest-mongodb',
|
||||
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/src/test'],
|
||||
};
|
||||
|
@ -43,10 +43,10 @@ class RequestController {
|
||||
const requestDefinition = this.getRequestDefinition({ connectionDefinition, request });
|
||||
|
||||
// Get parser variables from requestInput and deserialize
|
||||
const { args, input, lowdefyGlobal, state, urlQuery } = this.deserializeInputs(requestInput);
|
||||
const { event, input, lowdefyGlobal, state, urlQuery } = this.deserializeInputs(requestInput);
|
||||
|
||||
const { connectionProperties, requestProperties } = await this.parseOperators({
|
||||
args,
|
||||
event,
|
||||
arrayIndices,
|
||||
connection,
|
||||
input,
|
||||
@ -128,12 +128,12 @@ class RequestController {
|
||||
return requestDefinition;
|
||||
}
|
||||
|
||||
deserializeInputs({ args, input, lowdefyGlobal, state, urlQuery }) {
|
||||
return serializer.deserialize({ args, input, lowdefyGlobal, state, urlQuery });
|
||||
deserializeInputs({ event, input, lowdefyGlobal, state, urlQuery }) {
|
||||
return serializer.deserialize({ event, input, lowdefyGlobal, state, urlQuery });
|
||||
}
|
||||
|
||||
async parseOperators({
|
||||
args,
|
||||
event,
|
||||
arrayIndices,
|
||||
connection,
|
||||
input,
|
||||
@ -153,18 +153,18 @@ class RequestController {
|
||||
});
|
||||
|
||||
const { output: connectionProperties, errors: connectionErrors } = operatorsParser.parse({
|
||||
event,
|
||||
input: connection.properties || {},
|
||||
location: connection.connectionId,
|
||||
args,
|
||||
});
|
||||
if (connectionErrors.length > 0) {
|
||||
throw new RequestError(connectionErrors[0]);
|
||||
}
|
||||
|
||||
const { output: requestProperties, errors: requestErrors } = operatorsParser.parse({
|
||||
event,
|
||||
input: request.properties || {},
|
||||
location: request.requestId,
|
||||
args,
|
||||
});
|
||||
if (requestErrors.length > 0) {
|
||||
throw new RequestError(requestErrors[0]);
|
||||
|
@ -79,9 +79,9 @@ const loaders = {
|
||||
const context = testBootstrapContext({ loaders, getSecrets });
|
||||
|
||||
const defaultInput = {
|
||||
args: {},
|
||||
arrayIndices: [],
|
||||
blockId: 'contextId',
|
||||
event: {},
|
||||
input: {},
|
||||
lowdefyGlobal: {},
|
||||
pageId: 'pageId',
|
||||
@ -253,12 +253,12 @@ test('deserialize inputs', async () => {
|
||||
requestId: 'requestId',
|
||||
connectionId: 'testConnection',
|
||||
properties: {
|
||||
args: { _args: true },
|
||||
event: { _event: true },
|
||||
input: { _input: true },
|
||||
global: { _global: true },
|
||||
state: { _state: true },
|
||||
urlQuery: { _url_query: true },
|
||||
argsDate: { _args: 'date' },
|
||||
eventDate: { _event: 'date' },
|
||||
inputDate: { _input: 'date' },
|
||||
globalDate: { _global: 'date' },
|
||||
stateDate: { _state: 'date' },
|
||||
@ -271,11 +271,11 @@ test('deserialize inputs', async () => {
|
||||
resolvers.TestConnection.requests.TestRequest.resolver.mockImplementation(defaultResolverImp);
|
||||
const controller = createRequestController(context);
|
||||
await controller.callRequest({
|
||||
args: {
|
||||
date: { _date: 0 },
|
||||
},
|
||||
arrayIndices: [],
|
||||
blockId: 'contextId',
|
||||
event: {
|
||||
date: { _date: 0 },
|
||||
},
|
||||
input: {
|
||||
date: { _date: 0 },
|
||||
},
|
||||
@ -298,12 +298,12 @@ test('deserialize inputs', async () => {
|
||||
connectionProperty: 'connectionProperty',
|
||||
},
|
||||
request: {
|
||||
args: { date: new Date(0) },
|
||||
event: { date: new Date(0) },
|
||||
input: { date: new Date(0) },
|
||||
global: { date: new Date(0) },
|
||||
state: { date: new Date(0) },
|
||||
urlQuery: { date: new Date(0) },
|
||||
argsDate: new Date(0),
|
||||
eventDate: new Date(0),
|
||||
inputDate: new Date(0),
|
||||
globalDate: new Date(0),
|
||||
stateDate: new Date(0),
|
||||
@ -324,8 +324,8 @@ test('parse request properties for operators', async () => {
|
||||
requestId: 'requestId',
|
||||
connectionId: 'testConnection',
|
||||
properties: {
|
||||
args: { _args: 'value' },
|
||||
input: { _input: 'value' },
|
||||
event: { _event: 'value' },
|
||||
global: { _global: 'value' },
|
||||
state: { _state: 'value' },
|
||||
urlQuery: { _url_query: 'value' },
|
||||
@ -338,14 +338,14 @@ test('parse request properties for operators', async () => {
|
||||
resolvers.TestConnection.requests.TestRequest.resolver.mockImplementation(defaultResolverImp);
|
||||
const controller = createRequestController(context);
|
||||
const res = await controller.callRequest({
|
||||
args: {
|
||||
value: 'argValue',
|
||||
},
|
||||
arrayIndices: [1],
|
||||
blockId: 'contextId',
|
||||
input: {
|
||||
value: 'inputValue',
|
||||
},
|
||||
event: {
|
||||
value: 'eventValue',
|
||||
},
|
||||
lowdefyGlobal: {
|
||||
value: 'globalValue',
|
||||
},
|
||||
@ -366,7 +366,7 @@ test('parse request properties for operators', async () => {
|
||||
connectionProperty: 'connectionProperty',
|
||||
},
|
||||
request: {
|
||||
args: 'argValue',
|
||||
event: 'eventValue',
|
||||
input: 'inputValue',
|
||||
global: 'globalValue',
|
||||
state: 'stateValue',
|
||||
@ -387,7 +387,7 @@ test('parse connection properties for operators', async () => {
|
||||
type: 'TestConnection',
|
||||
connectionId: 'testConnection',
|
||||
properties: {
|
||||
args: { _args: 'value' },
|
||||
event: { _event: 'value' },
|
||||
input: { _input: 'value' },
|
||||
global: { _global: 'value' },
|
||||
state: { _state: 'value' },
|
||||
@ -402,11 +402,11 @@ test('parse connection properties for operators', async () => {
|
||||
resolvers.TestConnection.requests.TestRequest.resolver.mockImplementation(defaultResolverImp);
|
||||
const controller = createRequestController(context);
|
||||
const res = await controller.callRequest({
|
||||
args: {
|
||||
value: 'argValue',
|
||||
},
|
||||
arrayIndices: [1],
|
||||
blockId: 'contextId',
|
||||
event: {
|
||||
value: 'eventValue',
|
||||
},
|
||||
input: {
|
||||
value: 'inputValue',
|
||||
},
|
||||
@ -427,7 +427,7 @@ test('parse connection properties for operators', async () => {
|
||||
id: 'request:pageId:contextId:requestId',
|
||||
response: {
|
||||
connection: {
|
||||
args: 'argValue',
|
||||
event: 'eventValue',
|
||||
input: 'inputValue',
|
||||
global: 'globalValue',
|
||||
state: 'stateValue',
|
||||
|
@ -26,9 +26,9 @@ const typeDefs = gql`
|
||||
}
|
||||
|
||||
input RequestInput {
|
||||
args: JSON!
|
||||
arrayIndices: JSON!
|
||||
blockId: String!
|
||||
event: JSON!
|
||||
input: JSON!
|
||||
lowdefyGlobal: JSON!
|
||||
pageId: String!
|
||||
|
Loading…
Reference in New Issue
Block a user