Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (value && oldValue) {
const update = app.graphql.generateUpdate("Image", fields);
return update({ variables: { id: oldValue.id, data: value } }).then(
({ data }) => finish({ value: data })
);
}
next();
},
// Insert new image
({ value }, next, finish) => {
const create = app.graphql.generateCreate("Image", fields);
create({ variables: { data: value } }).then(({ data }) => finish({ value: data }));
}
];
compose(flow)({ value, oldValue: _.get(props.widget, "data.image") }).then(({ value }) =>
onChange(value)
);
}
}
export default (options: EndpointMiddlewareOptions = {}) => {
// Endpoint hooks in form of a middleware
const beforeApiMethodMiddleware = compose(_.get(options, "beforeApiMethod", []));
const afterApiMethodMiddleware = compose(_.get(options, "afterApiMethod", []));
return async (
params: {
req: express$Request,
res: express$Response,
versioning: Function,
response: Object
},
next: Function
) => {
const { req, res, versioning } = params;
const log = debug("api:endpoint");
log(`Trying to match an endpoint: %o`, req.method + " " + req.path);
const reqVersion = versioning(req);
if (value && oldValue) {
const update = app.graphql.generateUpdate("Image", fields);
return update({ variables: { id: oldValue.id, data: value } }).then(
({ data }) => finish({ value: data })
);
}
next();
},
// Insert new image
({ value }, next, finish) => {
const create = app.graphql.generateCreate("Image", fields);
create({ variables: { data: value } }).then(({ data }) => finish({ value: data }));
}
];
compose(flow)({ value, oldValue: _.get(props.widget, "data.image") }).then(({ value }) =>
onChange(value)
);
}
}
hooks.push(app[hook]);
}
});
if (this.config.hooks && this.config.hooks[hook]) {
hooks.push(this.config.hooks[hook]);
}
const params: Object = { api: this };
if (hook === "init") {
params.schema = schema;
}
try {
await compose(hooks)(params);
} catch (e) {
this.log(`An error occurred in the "${hook}" process:\n${e.stack}`, "error");
process.exit(1);
}
}
}
async setup() {
debug("Started setup");
this.config = await this.configLoader();
await compose(this.configurators)({ app: this });
this.initialized = true;
debug("Finished setup");
}
}
async setup() {
debug("Started setup");
this.config = await this.configLoader();
await compose(this.configurators)({ app: this });
this.initialized = true;
debug("Finished setup");
}
}
configure(config: Object) {
this.config = { ...config };
this.history = config.history;
this.middleware = compose(config.middleware);
this.match = null;
}
variables: context.event.body.variables,
operationName: context.event.body.operationName
};
next();
},
securityMiddleware(),
graphqlMiddleware(),
(context, next, finish) => {
if (context.output.errors) {
context.output.errors = context.output.errors.map(formatError);
}
finish(context);
}
];
export default compose(middleware);
configure(config: Object) {
this.config = { ...config };
this.history = config.history;
this.middleware = compose(config.middleware);
if (!this.history) {
this.history = createBrowserHistory();
}
}