Skip to content

Instantly share code, notes, and snippets.

@iamsuneeth
Last active November 30, 2023 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamsuneeth/dd33d31282222c96cfe6b35c06dfe21d to your computer and use it in GitHub Desktop.
Save iamsuneeth/dd33d31282222c96cfe6b35c06dfe21d to your computer and use it in GitHub Desktop.
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-param-reassign */
const { ObjectId } = require('mongodb');
function setConfigCreateBody(requestParams, context, ee, next) {
const contentId = new ObjectId();
requestParams.body = JSON.stringify({
query: `mutation UpsertConfigs($data: ConfigsInput!) {
upsertConfigs(data: $data) {
code
message
success
data {
contentId
}
}
}`,
variables: {
data: {
contentId
},
},
});
next();
}
function setConfigUpdateBody(requestParams, context, ee, next) {
requestParams.body = JSON.stringify({
query: `mutation UpsertLayoutConfigs($data: ConfigsInput!, $query: ConfigsQueryInput) {
upsertConfigs(data: $data, query: $query) {
code
message
success
data {
contentId
}
}
}`,
variables: {
data: {
contentId: context.vars.contentId
// other fields
},
query: {
contentId: context.vars.contentId,
},
},
});
next();
}
// ... other functions
module.exports = {
setLayoutConfigCreateBody,
// ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment