4a2ba8406d
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.
27 lines
643 B
TypeScript
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;
|
|
};
|
|
}
|