From ca549e93e5d792d916bbe94e94054c89835cac3a Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 5 May 2021 00:14:04 +0200 Subject: [PATCH] Split content block fragment into multiple parts --- .../graphql/gql/fragments/chapterParts.gql | 1 - .../fragments/contentBlockInterfaceParts.gql | 7 +++++++ .../gql/fragments/contentBlockParts.gql | 21 +++++-------------- .../graphql/gql/mutations/addContentBlock.gql | 2 ++ .../gql/mutations/mutateContentBlock.gql | 3 +++ .../gql/mutations/updateChapterVisibility.gql | 3 +++ .../queries/allContentBlocksCacheQuery.gql | 7 ------- .../src/graphql/gql/queries/chapterQuery.gql | 3 +++ .../graphql/gql/queries/contentBlockQuery.gql | 2 ++ .../queries/modules/moduleDetailsQuery.gql | 2 ++ .../graphql/gql/queries/snapshots/detail.gql | 9 +++++++- 11 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 client/src/graphql/gql/fragments/contentBlockInterfaceParts.gql delete mode 100644 client/src/graphql/gql/queries/allContentBlocksCacheQuery.gql diff --git a/client/src/graphql/gql/fragments/chapterParts.gql b/client/src/graphql/gql/fragments/chapterParts.gql index fb5c4e79..7a8901eb 100644 --- a/client/src/graphql/gql/fragments/chapterParts.gql +++ b/client/src/graphql/gql/fragments/chapterParts.gql @@ -1,4 +1,3 @@ -#import "./contentBlockParts.gql" fragment ChapterParts on ChapterNode { id title diff --git a/client/src/graphql/gql/fragments/contentBlockInterfaceParts.gql b/client/src/graphql/gql/fragments/contentBlockInterfaceParts.gql new file mode 100644 index 00000000..6a386e33 --- /dev/null +++ b/client/src/graphql/gql/fragments/contentBlockInterfaceParts.gql @@ -0,0 +1,7 @@ +fragment ContentBlockInterfaceParts on ContentBlockInterface { + id + title + type + contents + __typename +} diff --git a/client/src/graphql/gql/fragments/contentBlockParts.gql b/client/src/graphql/gql/fragments/contentBlockParts.gql index 31b8489a..c6bc8b6d 100644 --- a/client/src/graphql/gql/fragments/contentBlockParts.gql +++ b/client/src/graphql/gql/fragments/contentBlockParts.gql @@ -1,9 +1,5 @@ fragment ContentBlockParts on ContentBlockNode { - id slug - title - type - contents userCreated mine bookmarks { @@ -14,19 +10,12 @@ fragment ContentBlockParts on ContentBlockNode { } } hiddenFor { - edges { - node { - id - name - } - } + id + name } visibleFor { - edges { - node { - id - name - } - } + id + name } + } diff --git a/client/src/graphql/gql/mutations/addContentBlock.gql b/client/src/graphql/gql/mutations/addContentBlock.gql index c7893b4c..62eb1881 100644 --- a/client/src/graphql/gql/mutations/addContentBlock.gql +++ b/client/src/graphql/gql/mutations/addContentBlock.gql @@ -1,9 +1,11 @@ +#import "../fragments/contentBlockInterfaceParts.gql" #import "../fragments/contentBlockParts.gql" mutation AddContentBlock($input: AddContentBlockInput!) { addContentBlock(input: $input) { newContentBlock { ...ContentBlockParts + ...ContentBlockInterfaceParts } errors clientMutationId diff --git a/client/src/graphql/gql/mutations/mutateContentBlock.gql b/client/src/graphql/gql/mutations/mutateContentBlock.gql index 84761705..6934a065 100644 --- a/client/src/graphql/gql/mutations/mutateContentBlock.gql +++ b/client/src/graphql/gql/mutations/mutateContentBlock.gql @@ -1,9 +1,12 @@ +#import "../fragments/contentBlockInterfaceParts.gql" #import "../fragments/contentBlockParts.gql" mutation MutateContentBlock($input: MutateContentBlockInput!) { mutateContentBlock(input: $input) { contentBlock { ...ContentBlockParts + ...ContentBlockInterfaceParts + } } } diff --git a/client/src/graphql/gql/mutations/updateChapterVisibility.gql b/client/src/graphql/gql/mutations/updateChapterVisibility.gql index 14763c5a..35787dac 100644 --- a/client/src/graphql/gql/mutations/updateChapterVisibility.gql +++ b/client/src/graphql/gql/mutations/updateChapterVisibility.gql @@ -1,11 +1,14 @@ #import "../fragments/chapterParts.gql" +#import "../fragments/contentBlockInterfaceParts.gql" #import "../fragments/contentBlockParts.gql" + mutation UpdateChapterVisibility($input: UpdateChapterVisibilityInput!) { updateChapterVisibility(input: $input) { chapter { ...ChapterParts contentBlocks { ...ContentBlockParts + ...ContentBlockInterfaceParts } } } diff --git a/client/src/graphql/gql/queries/allContentBlocksCacheQuery.gql b/client/src/graphql/gql/queries/allContentBlocksCacheQuery.gql deleted file mode 100644 index bc7feed1..00000000 --- a/client/src/graphql/gql/queries/allContentBlocksCacheQuery.gql +++ /dev/null @@ -1,7 +0,0 @@ -# to be read from cache only -#import "../fragments/contentBlockParts.gql" -query ContentBlockQuery { - contentBlocks { - ...ContentBlockParts - } -} diff --git a/client/src/graphql/gql/queries/chapterQuery.gql b/client/src/graphql/gql/queries/chapterQuery.gql index 86d58454..9cdf882b 100644 --- a/client/src/graphql/gql/queries/chapterQuery.gql +++ b/client/src/graphql/gql/queries/chapterQuery.gql @@ -1,10 +1,13 @@ #import "../fragments/chapterParts.gql" +#import "../fragments/contentBlockInterfaceParts.gql" #import "../fragments/contentBlockParts.gql" + query ChapterQuery($id: ID!) { chapter(id: $id) { ...ChapterParts contentBlocks { ...ContentBlockParts + ...ContentBlockInterfaceParts } } } diff --git a/client/src/graphql/gql/queries/contentBlockQuery.gql b/client/src/graphql/gql/queries/contentBlockQuery.gql index 42f7d2e2..8dcad21a 100644 --- a/client/src/graphql/gql/queries/contentBlockQuery.gql +++ b/client/src/graphql/gql/queries/contentBlockQuery.gql @@ -1,6 +1,8 @@ +#import "../fragments/contentBlockInterfaceParts.gql" #import "../fragments/contentBlockParts.gql" query ContentBlockQuery($id: ID!) { contentBlock(id: $id) { ...ContentBlockParts + ...ContentBlockInterfaceParts } } diff --git a/client/src/graphql/gql/queries/modules/moduleDetailsQuery.gql b/client/src/graphql/gql/queries/modules/moduleDetailsQuery.gql index a006aa48..5dece44a 100644 --- a/client/src/graphql/gql/queries/modules/moduleDetailsQuery.gql +++ b/client/src/graphql/gql/queries/modules/moduleDetailsQuery.gql @@ -3,6 +3,7 @@ #import "../../fragments/objectiveGroupParts.gql" #import "../../fragments/objectiveParts.gql" #import "../../fragments/moduleParts.gql" +#import "../../fragments/contentBlockInterfaceParts.gql" #import "../../fragments/contentBlockParts.gql" query ModuleDetailsQuery($slug: String!) { module(slug: $slug) { @@ -33,6 +34,7 @@ query ModuleDetailsQuery($slug: String!) { node { ...ChapterParts contentBlocks { + ...ContentBlockInterfaceParts ...ContentBlockParts } } diff --git a/client/src/graphql/gql/queries/snapshots/detail.gql b/client/src/graphql/gql/queries/snapshots/detail.gql index 6373600d..409d27e7 100644 --- a/client/src/graphql/gql/queries/snapshots/detail.gql +++ b/client/src/graphql/gql/queries/snapshots/detail.gql @@ -1,6 +1,12 @@ +#import "../../fragments/contentBlockInterfaceParts.gql" + + query SnapshotDetail($id: ID!) { snapshot(id: $id) { id + title + metaTitle + heroImage chapters { id description @@ -8,7 +14,8 @@ query SnapshotDetail($id: ID!) { titleHidden descriptionHidden contentBlocks { - id + ...ContentBlockInterfaceParts + hidden } } }