kandimat/redaktions-app/src/backend/mutations/userRole.ts
Christoph Lienhard 4a2ba8406d
#20 Return person on change role mutation
Return the whole person object on calling the changeRole mutation.
This enables the apollo cache in the frontend to automatically
update the role of the given user.

Furthermore, made all create function statements idempotent by
deleting them first if existing.
2021-05-28 23:41:30 +02:00

27 lines
643 B
TypeScript

import { gql } from "@apollo/client";
import { UppercaseUserRole } from "../../jwt/jwt";
import { BasicPersonFragment, BasicPersonResponse } from "../queries/person";
export const ChangeRole = gql`
mutation ChangeRole($personRowId: Int!, $newRole: Role!) {
changeRole(input: { personRowId: $personRowId, newRole: $newRole }) {
person {
...BasicPersonFragment
}
}
}
${BasicPersonFragment}
`;
export interface ChangeRoleVariables {
personRowId: number;
newRole: UppercaseUserRole;
}
export interface ChangeRoleResponse {
__typename: "Mutation";
changeRole: {
person?: BasicPersonResponse;
};
}