kandimat/redaktions-app/src/backend/queries/question.ts
2021-01-09 12:49:28 +01:00

74 lines
1.3 KiB
TypeScript

import { gql } from "@apollo/client";
const QuestionCategoryFragment = gql`
fragment QuestionCategoryFragment on Category {
id
rowId
title
}
`;
interface GetQuestionsCategoryResponse {
id: string;
rowId: number;
title: string;
__typename: "Category";
}
export const BasicQuestionFragment = gql`
fragment BasicQuestionFragment on Question {
id
rowId
title
description
categoryByCategoryRowId {
...QuestionCategoryFragment
}
}
${QuestionCategoryFragment}
`;
export interface BasicQuestionResponse {
id: string;
rowId: number;
title: string;
description: string | null;
categoryByCategoryRowId: GetQuestionsCategoryResponse | null;
__typename: "Question";
}
export const GET_ALL_QUESTIONS = gql`
query AllQuestions {
allQuestions {
nodes {
...BasicQuestionFragment
}
}
}
${BasicQuestionFragment}
`;
export interface GetAllQuestionsResponse {
allQuestions: {
nodes: Array<BasicQuestionResponse>;
__typename: "QuestionsConnection";
};
}
export const GET_QUESTION_BY_ID = gql`
query GetQuestionById($id: ID!) {
question(id: $id) {
...BasicQuestionFragment
}
}
${BasicQuestionFragment}
`;
export interface GetQuestionByIdResponse {
question: BasicQuestionResponse | null;
}
export interface GetQuestionByIdVariables {
id: string;
}