add mutation to set item explicitly body specific
now that Support feature works!
This commit is contained in:
parent
b23f64ad53
commit
380cbf543b
1 changed files with 31 additions and 0 deletions
|
@ -207,6 +207,12 @@ const typeDefs = gql`
|
|||
supportSecret: String!
|
||||
): Item!
|
||||
|
||||
setItemExplicitlyBodySpecific(
|
||||
itemId: ID!
|
||||
explicitlyBodySpecific: Boolean!
|
||||
supportSecret: String!
|
||||
): Item!
|
||||
|
||||
setLayerBodyId(
|
||||
layerId: ID!
|
||||
bodyId: ID!
|
||||
|
@ -579,6 +585,31 @@ const resolvers = {
|
|||
return { id: itemId };
|
||||
},
|
||||
|
||||
setItemExplicitlyBodySpecific: async (
|
||||
_,
|
||||
{ itemId, explicitlyBodySpecific, supportSecret },
|
||||
{ db }
|
||||
) => {
|
||||
if (supportSecret !== process.env["SUPPORT_SECRET"]) {
|
||||
throw new Error(`Support secret is incorrect. Try setting up again?`);
|
||||
}
|
||||
|
||||
const [
|
||||
result,
|
||||
] = await db.execute(
|
||||
`UPDATE items SET explicitly_body_specific = ? WHERE id = ? LIMIT 1`,
|
||||
[explicitlyBodySpecific ? 1 : 0, itemId]
|
||||
);
|
||||
|
||||
if (result.affectedRows !== 1) {
|
||||
throw new Error(
|
||||
`Expected to affect 1 item, but affected ${result.affectedRows}`
|
||||
);
|
||||
}
|
||||
|
||||
return { id: itemId };
|
||||
},
|
||||
|
||||
setLayerBodyId: async (_, { layerId, bodyId, supportSecret }, { db }) => {
|
||||
if (supportSecret !== process.env["SUPPORT_SECRET"]) {
|
||||
throw new Error(`Support secret is incorrect. Try setting up again?`);
|
||||
|
|
Loading…
Reference in a new issue