Files
bodyshop/client/src/graphql/csi.queries.js
2021-02-24 08:48:55 -08:00

98 lines
1.7 KiB
JavaScript

import { gql } from "@apollo/client";
export const QUERY_SURVEY = gql`
query QUERY_SURVEY($surveyId: uuid!) {
csi_by_pk(id: $surveyId) {
relateddata
valid
validuntil
id
csiquestion {
id
config
}
}
}
`;
export const COMPLETE_SURVEY = gql`
mutation COMPLETE_SURVEY($surveyId: uuid!, $survey: csi_set_input) {
update_csi(where: { id: { _eq: $surveyId } }, _set: $survey) {
affected_rows
}
}
`;
export const GET_ALL_QUESTION_SETS = gql`
query GET_ALL_QUESTION_SETS {
csiquestions(order_by: { created_at: desc }) {
id
created_at
config
current
csis_aggregate {
aggregate {
count
}
}
}
}
`;
export const GET_CURRENT_QUESTIONSET_ID = gql`
query GET_CURRENT_QUESTIONSET_ID {
csiquestions(where: { current: { _eq: true } }) {
id
}
}
`;
export const INSERT_CSI = gql`
mutation INSERT_CSI($csiInput: [csi_insert_input!]!) {
insert_csi(objects: $csiInput) {
returning {
id
}
}
}
`;
export const QUERY_CSI_RESPONSE_PAGINATED = gql`
query QUERY_CSI_RESPONSE_PAGINATED(
$offset: Int
$limit: Int
$order: [csi_order_by!]!
) {
csi(offset: $offset, limit: $limit, order_by: $order) {
id
completedon
job {
ownr_fn
ownr_ln
ro_number
id
}
}
csi_aggregate {
aggregate {
count(distinct: true)
}
}
}
`;
export const QUERY_CSI_RESPONSE_BY_PK = gql`
query QUERY_CSI_RESPONSE_BY_PK($id: uuid!) {
csi_by_pk(id: $id) {
relateddata
valid
validuntil
id
response
csiquestion {
id
config
}
}
}
`;