kandimat/redaktions-app/src/backend/queries/question.ts
Christoph Lienhard 587c0cdeba
#11 Add integration test for editing a question
Also:
* introduce __typename to all response types
2020-12-30 01:10:30 +01:00

55 lines
1,023 B
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
title
description
categoryByCategoryRowId {
...QuestionCategoryFragment
}
}
${QuestionCategoryFragment}
`
export interface BasicQuestionResponse {
id: string,
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",
}
}