Skip to content

Commit

Permalink
Merge pull request #60 from the-deep/fix/add-missing-id-in-queries
Browse files Browse the repository at this point in the history
Add missing ids in queries
  • Loading branch information
subinasr authored Sep 27, 2023
2 parents ebd963f + 232dfb1 commit 27f1464
Show file tree
Hide file tree
Showing 27 changed files with 111 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const ADD_OPTIONS = gql`
$input: QuestionChoiceCollectionCreateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
createQuestionChoiceCollection(
data: $input,
) {
Expand Down Expand Up @@ -86,7 +88,9 @@ const EDIT_OPTIONS = gql`
$choiceCollectionId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestionChoiceCollection(
data: $input,
id: $choiceCollectionId,
Expand Down Expand Up @@ -117,6 +121,7 @@ const COLLECTION = gql`
$choiceCollectionId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
choiceCollection(pk: $choiceCollectionId) {
Expand Down
1 change: 1 addition & 0 deletions src/components/ChoiceCollectionSelectInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const CHOICE_COLLECTIONS = gql`
$search:String
) {
private {
id
projectScope(pk: $projectId) {
id
choiceCollections(
Expand Down
6 changes: 6 additions & 0 deletions src/components/EditQuestionnaireModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const CREATE_QUESTIONNAIRE = gql`
$input: QuestionnaireCreateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
createQuestionnaire(data: $input) {
errors
ok
Expand All @@ -59,7 +61,9 @@ const EDIT_QUESTIONNAIRE = gql`
$input: QuestionnaireUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestionnaire(data: $input, id: $questionnaireId) {
errors
ok
Expand All @@ -79,7 +83,9 @@ const QUESTIONNAIRE_DETAIL = gql`
$questionnaireId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
questionnaire(pk: $questionnaireId) {
id
title
Expand Down
3 changes: 3 additions & 0 deletions src/components/PillarSelectInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ const PILLARS = gql`
$questionnaireId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
questionnaire(pk: $questionnaireId) {
id
leafGroups {
id
name
Expand Down
1 change: 1 addition & 0 deletions src/components/ProjectCreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const CREATE_PROJECT = gql`
$input: ProjectCreateInput!,
) {
private {
id
createProject(data: $input) {
errors
ok
Expand Down
1 change: 1 addition & 0 deletions src/components/ProjectMembershipEditModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const UPDATE_MEMBERSHIP = gql`
$membershipId: ID,
) {
private {
id
projectScope(pk: $projectId) {
id
updateMemberships(
Expand Down
1 change: 1 addition & 0 deletions src/components/UserSelectInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const USERS = gql`
$search: String,
) {
private {
id
users(
pagination: {
limit: $limit,
Expand Down
1 change: 1 addition & 0 deletions src/views/About/QuestionsPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const QUESTIONS_FROM_BANK = gql`
$leafGroupId: ID!,
) {
private {
id
qbQuestions(
filters: {
qbank: {pk: $questionBankId}
Expand Down
28 changes: 11 additions & 17 deletions src/views/About/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ import QuestionsPreview from './QuestionsPreview';
import IntroText from './IntroText';
import styles from './index.module.css';

const QUESTION_BANK_ID = '1';

const ABOUT_FRAMEWORK = gql`
query AboutFramework (
$questionBankId: ID!,
){
query AboutFramework {
private {
questionBank(pk: $questionBankId) {
id
activeQuestionBank {
id
leafGroups {
category1
category1Display
Expand Down Expand Up @@ -70,8 +68,8 @@ const ABOUT_FRAMEWORK = gql`
}
`;

type QuestionGroup = NonNullable<NonNullable<AboutFrameworkQuery['private']>['questionBank']>['leafGroups'][number];
export type ChoiceCollectionsType = NonNullable<NonNullable<AboutFrameworkQuery['private']>['questionBank']>['choiceCollections'];
type QuestionGroup = NonNullable<NonNullable<AboutFrameworkQuery['private']>['activeQuestionBank']>['leafGroups'][number];
export type ChoiceCollectionsType = NonNullable<NonNullable<AboutFrameworkQuery['private']>['activeQuestionBank']>['choiceCollections'];

const subPillarKeySelector = (group: QuestionGroup) => group.id;

Expand Down Expand Up @@ -211,17 +209,13 @@ export function Component() {
data: frameworkResponse,
} = useQuery<AboutFrameworkQuery, AboutFrameworkQueryVariables>(
ABOUT_FRAMEWORK,
{
variables: {
questionBankId: QUESTION_BANK_ID,
},
},
);

const [selectedLeafGroupIds, setSelectedLeafGroupIds] = useState<string[]>([]);
const framework = frameworkResponse?.private?.questionBank?.leafGroups;
const bankId = frameworkResponse?.private?.activeQuestionBank?.id;
const framework = frameworkResponse?.private?.activeQuestionBank?.leafGroups;

const choiceCollections = frameworkResponse?.private?.questionBank?.choiceCollections;
const choiceCollections = frameworkResponse?.private?.activeQuestionBank?.choiceCollections;

const getLeafNodeLabel = useCallback((leafId: string): string | undefined => {
const leafNodeItem = framework?.find((group) => group.id === leafId);
Expand Down Expand Up @@ -319,7 +313,7 @@ export function Component() {
))}
</table>
</div>
{rightPaneShown && (
{rightPaneShown && bankId && (
<Container
className={styles.rightPane}
headerActions={(
Expand All @@ -345,7 +339,7 @@ export function Component() {
>
<QuestionsPreview
leafGroupId={leafGroupId}
questionBankId={QUESTION_BANK_ID}
questionBankId={bankId}
choiceCollections={choiceCollections}
/>
</Container>
Expand Down
6 changes: 6 additions & 0 deletions src/views/Home/QuestionnaireItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ const DELETE_QUESTIONNAIRE = gql`
$projectId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
deleteQuestionnaire(id: $questionnaireId){
errors
ok
Expand All @@ -73,7 +75,9 @@ const EXPORT_QUESTIONNAIRE = gql`
$questionnaireId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
createQuestionnaireExport(
data: {
questionnaire: $questionnaireId
Expand All @@ -100,7 +104,9 @@ const EXPORT_DETAILS = gql`
$exportId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
questionnaireExport(pk: $exportId) {
endedAt
enketoPreviewUrl
Expand Down
2 changes: 2 additions & 0 deletions src/views/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const PROJECTS = gql`
$offset: Int,
) {
private {
id
projects (
filters: {
search: $search,
Expand Down Expand Up @@ -69,6 +70,7 @@ const QUESTIONNAIRES_FOR_PROJECT = gql`
$projectId: ID!,
) {
private {
id
projectScope(pk: $projectId){
id
questionnaires {
Expand Down
5 changes: 5 additions & 0 deletions src/views/ProjectEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ const MEMBERSHIPS = gql`
$projectId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
project {
id
title
Expand Down Expand Up @@ -96,7 +98,9 @@ const UPDATE_PROJECT = gql`
$input: ProjectUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateProject(data: $input) {
errors
ok
Expand Down Expand Up @@ -129,6 +133,7 @@ const DELETE_MEMBERSHIP = gql`
$membershipIdToDelete: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateMemberships(deleteIds: [$membershipIdToDelete]) {
Expand Down
4 changes: 4 additions & 0 deletions src/views/QuestionnaireEdit/DateQuestionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const CREATE_DATE_QUESTION = gql`
$input: QuestionCreateInput!,
){
private {
id
projectScope(pk: $projectId) {
id
createQuestion(
data: $input,
) {
Expand All @@ -88,7 +90,9 @@ const UPDATE_DATE_QUESTION = gql`
$input: QuestionUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestion (
data: $input
id: $questionId,
Expand Down
4 changes: 4 additions & 0 deletions src/views/QuestionnaireEdit/FileQuestionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const CREATE_FILE_QUESTION = gql`
$input: QuestionCreateInput!,
){
private {
id
projectScope(pk: $projectId) {
id
createQuestion(
data: $input,
) {
Expand All @@ -88,7 +90,9 @@ const UPDATE_FILE_QUESTION = gql`
$input: QuestionUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestion (
data: $input
id: $questionId,
Expand Down
4 changes: 4 additions & 0 deletions src/views/QuestionnaireEdit/ImageQuestionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const CREATE_IMAGE_QUESTION = gql`
$input: QuestionCreateInput!,
){
private {
id
projectScope(pk: $projectId) {
id
createQuestion(
data: $input,
) {
Expand All @@ -88,7 +90,9 @@ const UPDATE_IMAGE_QUESTION = gql`
$input: QuestionUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestion (
data: $input
id: $questionId,
Expand Down
4 changes: 4 additions & 0 deletions src/views/QuestionnaireEdit/IntegerQuestionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const CREATE_INTEGER_QUESTION = gql`
$input: QuestionCreateInput!,
){
private {
id
projectScope(pk: $projectId) {
id
createQuestion(
data: $input,
) {
Expand All @@ -88,7 +90,9 @@ const UPDATE_INTEGER_QUESTION = gql`
$input: QuestionUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestion (
data: $input
id: $questionId,
Expand Down
4 changes: 4 additions & 0 deletions src/views/QuestionnaireEdit/NoteQuestionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const CREATE_NOTE_QUESTION = gql`
$input: QuestionCreateInput!,
){
private {
id
projectScope(pk: $projectId) {
id
createQuestion(
data: $input,
) {
Expand All @@ -72,7 +74,9 @@ const UPDATE_NOTE_QUESTION = gql`
$input: QuestionUpdateInput!,
) {
private {
id
projectScope(pk: $projectId) {
id
updateQuestion (
data: $input
id: $questionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ const DELETE_QUESTION = gql`
$questionId: ID!,
) {
private {
id
projectScope(pk: $projectId) {
id
deleteQuestion(id: $questionId) {
errors
ok
Expand Down
Loading

0 comments on commit 27f1464

Please sign in to comment.