Skip to content

Commit

Permalink
Provide parent data when resolving with cloud function
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Schulz committed Oct 27, 2023
1 parent 4b52366 commit e35b19b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/GraphQL/loaders/schemaDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const load = parseGraphQLSchema => {
auth,
info,
body: args,
parent: {
className: gqlInfo?.parentType,
..._source,
},
})
).response.result;
} catch (e) {
Expand Down
10 changes: 7 additions & 3 deletions src/Routers/FunctionsRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ export class FunctionsRouter extends PromiseRouter {
};
}
static handleCloudFunction(req) {
const functionName = req.params.functionName;
const applicationId = req.config.applicationId;
const {
params: { functionName },
config: { applicationId },
parent,
} = req;
const theFunction = triggers.getFunction(functionName, applicationId);

if (!theFunction) {
Expand All @@ -122,7 +125,7 @@ export class FunctionsRouter extends PromiseRouter {
let params = Object.assign({}, req.body, req.query);
params = parseParams(params);
const request = {
params: params,
params,
master: req.auth && req.auth.isMaster,
user: req.auth && req.auth.user,
installationId: req.info.installationId,
Expand All @@ -131,6 +134,7 @@ export class FunctionsRouter extends PromiseRouter {
ip: req.config.ip,
functionName,
context: req.info.context,
parent,
};

return new Promise(function (resolve, reject) {
Expand Down

0 comments on commit e35b19b

Please sign in to comment.