From 556043c0d729243cd0a90f913d44f61b2a74fa2d Mon Sep 17 00:00:00 2001 From: Thibaud Date: Wed, 17 May 2023 17:56:02 +0200 Subject: [PATCH 1/3] :card_file_box: replace TagLabel with Subject in db --- .../Home/components/Searchbar/Searchbar.jsx | 4 +- e2e/client.test.js | 4 +- server/prisma/datamodel.graphql | 12 +- server/scripts/tmp_tag_resync/part1.js | 8 +- server/src/generated/prisma.graphql | 713 +++++++++--------- server/src/helpers/diffTags.js | 6 +- server/src/resolvers/question.js | 20 +- server/src/schema.graphql | 4 +- 8 files changed, 384 insertions(+), 387 deletions(-) diff --git a/client/src/scenes/Home/components/Searchbar/Searchbar.jsx b/client/src/scenes/Home/components/Searchbar/Searchbar.jsx index d01d5ca70..277bd8160 100644 --- a/client/src/scenes/Home/components/Searchbar/Searchbar.jsx +++ b/client/src/scenes/Home/components/Searchbar/Searchbar.jsx @@ -13,7 +13,7 @@ const Searchbar = ({ text, tags, loading, onTextChange, onTagsChange }) => { const intl = getIntl(Searchbar) const conf = useConfiguration() - const tagLabels = tags + const subjects = tags .map(tag => conf.tagCategories .reduce((acc, cat) => acc.concat(cat.labels), []) @@ -45,7 +45,7 @@ const Searchbar = ({ text, tags, loading, onTextChange, onTagsChange }) => { diff --git a/e2e/client.test.js b/e2e/client.test.js index 29982e301..35d95c91b 100644 --- a/e2e/client.test.js +++ b/e2e/client.test.js @@ -139,7 +139,7 @@ const upsertConfigMutation = async apiContext => { const tagsId = /* GraphQL */ ` query GetAllTags { - tagLabels { + subjects { id name } @@ -153,7 +153,7 @@ const tagsQuery = async apiContext => { } }) const jsonRes = await res.json() - const results = await jsonRes.data.tagLabels + const results = await jsonRes.data.subjects const tag = results[0] const tagEdit = results[1] return { tag, tagEdit } diff --git a/server/prisma/datamodel.graphql b/server/prisma/datamodel.graphql index 9bda86629..5fc33ce95 100644 --- a/server/prisma/datamodel.graphql +++ b/server/prisma/datamodel.graphql @@ -68,7 +68,7 @@ type Flag { type Tag { id: ID! @unique @id - label: TagLabel @relation(name: "TagsLabel", link: TABLE) + label: Subject @relation(name: "Tags", link: TABLE) node: ZNode! @relation(name: "NodeTags") user: User! @relation(name: "UserTags", link: TABLE) @@ -77,15 +77,15 @@ type Tag { updatedAt: DateTime! @updatedAt } -type TagLabel { +type Subject { id: ID! @unique @id name: String! - tags: [Tag!]! @relation(name: "TagsLabel", onDelete: CASCADE) + tags: [Tag!]! @relation(name: "Tags", onDelete: CASCADE) specialists: [User!]! @relation(name: "UserSpecialties", link: TABLE) order: Int! - category: TagCategory! @relation(name: "TagLabelsCategory", link: TABLE) + category: TagCategory! @relation(name: "SubjectsCategory", link: TABLE) createdAt: DateTime! @createdAt updatedAt: DateTime! @updatedAt @@ -95,7 +95,7 @@ type TagCategory { id: ID! @unique @id name: String! - labels: [TagLabel!]! @relation(name: "TagLabelsCategory", onDelete: CASCADE) + labels: [Subject!]! @relation(name: "SubjectsCategory", onDelete: CASCADE) order: Int! configuration: Configuration! @relation(name: "ConfigurationTags", link: TABLE) @@ -136,7 +136,7 @@ type User { flags: [Flag!]! @relation(name: "UserFlags") tags: [Tag!]! @relation(name: "UserTags") - specialties: [TagLabel!]! @relation(name: "UserSpecialties") + specialties: [Subject!]! @relation(name: "UserSpecialties") history: [HistoryAction!]! @relation(name: "UserHistoryActions") diff --git a/server/scripts/tmp_tag_resync/part1.js b/server/scripts/tmp_tag_resync/part1.js index e6ba71045..6513a2a98 100644 --- a/server/scripts/tmp_tag_resync/part1.js +++ b/server/scripts/tmp_tag_resync/part1.js @@ -50,7 +50,7 @@ const resync = async (name, stage) => { ) ) - const tagLabels = tagsCategories.reduce((acc, cat) => acc.concat(cat.labels), []) + const subjects = tagsCategories.reduce((acc, cat) => acc.concat(cat.labels), []) const tags = await prisma.query.tags( null, @@ -64,8 +64,8 @@ const resync = async (name, stage) => { return Promise.all( tags.map(tag => { - const tagLabel = tagLabels.find(label => label.name === tag.label) - if (!tagLabel) { + const subject = subjects.find(label => label.name === tag.label) + if (!subject) { console.log(`Unknown tag "${tag.label}" on "${tag.id}"`) return } @@ -73,7 +73,7 @@ const resync = async (name, stage) => { where: { id: tag.id }, data: { // label: null, // I'll manually remove label. This is a security in case something goes wrong - tagLabel: { connect: { id: tagLabel.id } } + subject: { connect: { id: subject.id } } } }) }) diff --git a/server/src/generated/prisma.graphql b/server/src/generated/prisma.graphql index bb6d875f8..04e384400 100644 --- a/server/src/generated/prisma.graphql +++ b/server/src/generated/prisma.graphql @@ -22,15 +22,15 @@ type AggregateSource { count: Int! } -type AggregateTag { +type AggregateSubject { count: Int! } -type AggregateTagCategory { +type AggregateTag { count: Int! } -type AggregateTagLabel { +type AggregateTagCategory { count: Int! } @@ -1448,6 +1448,16 @@ type Mutation { ): Source! deleteSource(where: SourceWhereUniqueInput!): Source deleteManySources(where: SourceWhereInput): BatchPayload! + createSubject(data: SubjectCreateInput!): Subject! + updateSubject(data: SubjectUpdateInput!, where: SubjectWhereUniqueInput!): Subject + updateManySubjects(data: SubjectUpdateManyMutationInput!, where: SubjectWhereInput): BatchPayload! + upsertSubject( + where: SubjectWhereUniqueInput! + create: SubjectCreateInput! + update: SubjectUpdateInput! + ): Subject! + deleteSubject(where: SubjectWhereUniqueInput!): Subject + deleteManySubjects(where: SubjectWhereInput): BatchPayload! createTag(data: TagCreateInput!): Tag! updateTag(data: TagUpdateInput!, where: TagWhereUniqueInput!): Tag upsertTag(where: TagWhereUniqueInput!, create: TagCreateInput!, update: TagUpdateInput!): Tag! @@ -1466,19 +1476,6 @@ type Mutation { ): TagCategory! deleteTagCategory(where: TagCategoryWhereUniqueInput!): TagCategory deleteManyTagCategories(where: TagCategoryWhereInput): BatchPayload! - createTagLabel(data: TagLabelCreateInput!): TagLabel! - updateTagLabel(data: TagLabelUpdateInput!, where: TagLabelWhereUniqueInput!): TagLabel - updateManyTagLabels( - data: TagLabelUpdateManyMutationInput! - where: TagLabelWhereInput - ): BatchPayload! - upsertTagLabel( - where: TagLabelWhereUniqueInput! - create: TagLabelCreateInput! - update: TagLabelUpdateInput! - ): TagLabel! - deleteTagLabel(where: TagLabelWhereUniqueInput!): TagLabel - deleteManyTagLabels(where: TagLabelWhereInput): BatchPayload! createUser(data: UserCreateInput!): User! updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User updateManyUsers(data: UserUpdateManyMutationInput!, where: UserWhereInput): BatchPayload! @@ -1633,6 +1630,25 @@ type Query { first: Int last: Int ): SourceConnection! + subject(where: SubjectWhereUniqueInput!): Subject + subjects( + where: SubjectWhereInput + orderBy: SubjectOrderByInput + skip: Int + after: String + before: String + first: Int + last: Int + ): [Subject]! + subjectsConnection( + where: SubjectWhereInput + orderBy: SubjectOrderByInput + skip: Int + after: String + before: String + first: Int + last: Int + ): SubjectConnection! tag(where: TagWhereUniqueInput!): Tag tags( where: TagWhereInput @@ -1671,25 +1687,6 @@ type Query { first: Int last: Int ): TagCategoryConnection! - tagLabel(where: TagLabelWhereUniqueInput!): TagLabel - tagLabels( - where: TagLabelWhereInput - orderBy: TagLabelOrderByInput - skip: Int - after: String - before: String - first: Int - last: Int - ): [TagLabel]! - tagLabelsConnection( - where: TagLabelWhereInput - orderBy: TagLabelOrderByInput - skip: Int - after: String - before: String - first: Int - last: Int - ): TagLabelConnection! user(where: UserWhereUniqueInput!): User users( where: UserWhereInput @@ -2315,91 +2312,93 @@ input SourceWhereUniqueInput { id: ID } -type Subscription { - answer(where: AnswerSubscriptionWhereInput): AnswerSubscriptionPayload - configuration(where: ConfigurationSubscriptionWhereInput): ConfigurationSubscriptionPayload - flag(where: FlagSubscriptionWhereInput): FlagSubscriptionPayload - historyAction(where: HistoryActionSubscriptionWhereInput): HistoryActionSubscriptionPayload - question(where: QuestionSubscriptionWhereInput): QuestionSubscriptionPayload - source(where: SourceSubscriptionWhereInput): SourceSubscriptionPayload - tag(where: TagSubscriptionWhereInput): TagSubscriptionPayload - tagCategory(where: TagCategorySubscriptionWhereInput): TagCategorySubscriptionPayload - tagLabel(where: TagLabelSubscriptionWhereInput): TagLabelSubscriptionPayload - user(where: UserSubscriptionWhereInput): UserSubscriptionPayload - zNode(where: ZNodeSubscriptionWhereInput): ZNodeSubscriptionPayload -} - -type Tag { - id: ID! - label: TagLabel - node: ZNode! - user: User! - createdAt: DateTime! - updatedAt: DateTime! -} - -type TagCategory { +type Subject { id: ID! name: String! - labels( - where: TagLabelWhereInput - orderBy: TagLabelOrderByInput + tags( + where: TagWhereInput + orderBy: TagOrderByInput skip: Int after: String before: String first: Int last: Int - ): [TagLabel!] + ): [Tag!] + specialists( + where: UserWhereInput + orderBy: UserOrderByInput + skip: Int + after: String + before: String + first: Int + last: Int + ): [User!] order: Int! - configuration: Configuration! + category: TagCategory! createdAt: DateTime! updatedAt: DateTime! } -type TagCategoryConnection { +type SubjectConnection { pageInfo: PageInfo! - edges: [TagCategoryEdge]! - aggregate: AggregateTagCategory! + edges: [SubjectEdge]! + aggregate: AggregateSubject! } -input TagCategoryCreateInput { +input SubjectCreateInput { id: ID name: String! - labels: TagLabelCreateManyWithoutCategoryInput + tags: TagCreateManyWithoutLabelInput + specialists: UserCreateManyWithoutSpecialtiesInput order: Int! - configuration: ConfigurationCreateOneWithoutTagCategoriesInput! + category: TagCategoryCreateOneWithoutLabelsInput! } -input TagCategoryCreateManyWithoutConfigurationInput { - create: [TagCategoryCreateWithoutConfigurationInput!] - connect: [TagCategoryWhereUniqueInput!] +input SubjectCreateManyWithoutCategoryInput { + create: [SubjectCreateWithoutCategoryInput!] + connect: [SubjectWhereUniqueInput!] } -input TagCategoryCreateOneWithoutLabelsInput { - create: TagCategoryCreateWithoutLabelsInput - connect: TagCategoryWhereUniqueInput +input SubjectCreateManyWithoutSpecialistsInput { + create: [SubjectCreateWithoutSpecialistsInput!] + connect: [SubjectWhereUniqueInput!] } -input TagCategoryCreateWithoutConfigurationInput { +input SubjectCreateOneWithoutTagsInput { + create: SubjectCreateWithoutTagsInput + connect: SubjectWhereUniqueInput +} + +input SubjectCreateWithoutCategoryInput { id: ID name: String! - labels: TagLabelCreateManyWithoutCategoryInput + tags: TagCreateManyWithoutLabelInput + specialists: UserCreateManyWithoutSpecialtiesInput order: Int! } -input TagCategoryCreateWithoutLabelsInput { +input SubjectCreateWithoutSpecialistsInput { id: ID name: String! + tags: TagCreateManyWithoutLabelInput order: Int! - configuration: ConfigurationCreateOneWithoutTagCategoriesInput! + category: TagCategoryCreateOneWithoutLabelsInput! } -type TagCategoryEdge { - node: TagCategory! +input SubjectCreateWithoutTagsInput { + id: ID + name: String! + specialists: UserCreateManyWithoutSpecialtiesInput + order: Int! + category: TagCategoryCreateOneWithoutLabelsInput! +} + +type SubjectEdge { + node: Subject! cursor: String! } -enum TagCategoryOrderByInput { +enum SubjectOrderByInput { id_ASC id_DESC name_ASC @@ -2412,7 +2411,7 @@ enum TagCategoryOrderByInput { updatedAt_DESC } -type TagCategoryPreviousValues { +type SubjectPreviousValues { id: ID! name: String! order: Int! @@ -2420,7 +2419,7 @@ type TagCategoryPreviousValues { updatedAt: DateTime! } -input TagCategoryScalarWhereInput { +input SubjectScalarWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2473,99 +2472,134 @@ input TagCategoryScalarWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [TagCategoryScalarWhereInput!] - OR: [TagCategoryScalarWhereInput!] - NOT: [TagCategoryScalarWhereInput!] + AND: [SubjectScalarWhereInput!] + OR: [SubjectScalarWhereInput!] + NOT: [SubjectScalarWhereInput!] } -type TagCategorySubscriptionPayload { +type SubjectSubscriptionPayload { mutation: MutationType! - node: TagCategory + node: Subject updatedFields: [String!] - previousValues: TagCategoryPreviousValues + previousValues: SubjectPreviousValues } -input TagCategorySubscriptionWhereInput { +input SubjectSubscriptionWhereInput { mutation_in: [MutationType!] updatedFields_contains: String updatedFields_contains_every: [String!] updatedFields_contains_some: [String!] - node: TagCategoryWhereInput - AND: [TagCategorySubscriptionWhereInput!] - OR: [TagCategorySubscriptionWhereInput!] - NOT: [TagCategorySubscriptionWhereInput!] + node: SubjectWhereInput + AND: [SubjectSubscriptionWhereInput!] + OR: [SubjectSubscriptionWhereInput!] + NOT: [SubjectSubscriptionWhereInput!] } -input TagCategoryUpdateInput { +input SubjectUpdateInput { name: String - labels: TagLabelUpdateManyWithoutCategoryInput + tags: TagUpdateManyWithoutLabelInput + specialists: UserUpdateManyWithoutSpecialtiesInput order: Int - configuration: ConfigurationUpdateOneRequiredWithoutTagCategoriesInput + category: TagCategoryUpdateOneRequiredWithoutLabelsInput } -input TagCategoryUpdateManyDataInput { +input SubjectUpdateManyDataInput { name: String order: Int } -input TagCategoryUpdateManyMutationInput { +input SubjectUpdateManyMutationInput { name: String order: Int } -input TagCategoryUpdateManyWithoutConfigurationInput { - create: [TagCategoryCreateWithoutConfigurationInput!] - delete: [TagCategoryWhereUniqueInput!] - connect: [TagCategoryWhereUniqueInput!] - set: [TagCategoryWhereUniqueInput!] - disconnect: [TagCategoryWhereUniqueInput!] - update: [TagCategoryUpdateWithWhereUniqueWithoutConfigurationInput!] - upsert: [TagCategoryUpsertWithWhereUniqueWithoutConfigurationInput!] - deleteMany: [TagCategoryScalarWhereInput!] - updateMany: [TagCategoryUpdateManyWithWhereNestedInput!] +input SubjectUpdateManyWithoutCategoryInput { + create: [SubjectCreateWithoutCategoryInput!] + delete: [SubjectWhereUniqueInput!] + connect: [SubjectWhereUniqueInput!] + set: [SubjectWhereUniqueInput!] + disconnect: [SubjectWhereUniqueInput!] + update: [SubjectUpdateWithWhereUniqueWithoutCategoryInput!] + upsert: [SubjectUpsertWithWhereUniqueWithoutCategoryInput!] + deleteMany: [SubjectScalarWhereInput!] + updateMany: [SubjectUpdateManyWithWhereNestedInput!] } -input TagCategoryUpdateManyWithWhereNestedInput { - where: TagCategoryScalarWhereInput! - data: TagCategoryUpdateManyDataInput! +input SubjectUpdateManyWithoutSpecialistsInput { + create: [SubjectCreateWithoutSpecialistsInput!] + delete: [SubjectWhereUniqueInput!] + connect: [SubjectWhereUniqueInput!] + set: [SubjectWhereUniqueInput!] + disconnect: [SubjectWhereUniqueInput!] + update: [SubjectUpdateWithWhereUniqueWithoutSpecialistsInput!] + upsert: [SubjectUpsertWithWhereUniqueWithoutSpecialistsInput!] + deleteMany: [SubjectScalarWhereInput!] + updateMany: [SubjectUpdateManyWithWhereNestedInput!] } -input TagCategoryUpdateOneRequiredWithoutLabelsInput { - create: TagCategoryCreateWithoutLabelsInput - update: TagCategoryUpdateWithoutLabelsDataInput - upsert: TagCategoryUpsertWithoutLabelsInput - connect: TagCategoryWhereUniqueInput +input SubjectUpdateManyWithWhereNestedInput { + where: SubjectScalarWhereInput! + data: SubjectUpdateManyDataInput! } -input TagCategoryUpdateWithoutConfigurationDataInput { +input SubjectUpdateOneWithoutTagsInput { + create: SubjectCreateWithoutTagsInput + update: SubjectUpdateWithoutTagsDataInput + upsert: SubjectUpsertWithoutTagsInput + delete: Boolean + disconnect: Boolean + connect: SubjectWhereUniqueInput +} + +input SubjectUpdateWithoutCategoryDataInput { name: String - labels: TagLabelUpdateManyWithoutCategoryInput + tags: TagUpdateManyWithoutLabelInput + specialists: UserUpdateManyWithoutSpecialtiesInput order: Int } -input TagCategoryUpdateWithoutLabelsDataInput { +input SubjectUpdateWithoutSpecialistsDataInput { name: String + tags: TagUpdateManyWithoutLabelInput order: Int - configuration: ConfigurationUpdateOneRequiredWithoutTagCategoriesInput + category: TagCategoryUpdateOneRequiredWithoutLabelsInput } -input TagCategoryUpdateWithWhereUniqueWithoutConfigurationInput { - where: TagCategoryWhereUniqueInput! - data: TagCategoryUpdateWithoutConfigurationDataInput! +input SubjectUpdateWithoutTagsDataInput { + name: String + specialists: UserUpdateManyWithoutSpecialtiesInput + order: Int + category: TagCategoryUpdateOneRequiredWithoutLabelsInput } -input TagCategoryUpsertWithoutLabelsInput { - update: TagCategoryUpdateWithoutLabelsDataInput! - create: TagCategoryCreateWithoutLabelsInput! +input SubjectUpdateWithWhereUniqueWithoutCategoryInput { + where: SubjectWhereUniqueInput! + data: SubjectUpdateWithoutCategoryDataInput! } -input TagCategoryUpsertWithWhereUniqueWithoutConfigurationInput { - where: TagCategoryWhereUniqueInput! - update: TagCategoryUpdateWithoutConfigurationDataInput! - create: TagCategoryCreateWithoutConfigurationInput! +input SubjectUpdateWithWhereUniqueWithoutSpecialistsInput { + where: SubjectWhereUniqueInput! + data: SubjectUpdateWithoutSpecialistsDataInput! } -input TagCategoryWhereInput { +input SubjectUpsertWithoutTagsInput { + update: SubjectUpdateWithoutTagsDataInput! + create: SubjectCreateWithoutTagsInput! +} + +input SubjectUpsertWithWhereUniqueWithoutCategoryInput { + where: SubjectWhereUniqueInput! + update: SubjectUpdateWithoutCategoryDataInput! + create: SubjectCreateWithoutCategoryInput! +} + +input SubjectUpsertWithWhereUniqueWithoutSpecialistsInput { + where: SubjectWhereUniqueInput! + update: SubjectUpdateWithoutSpecialistsDataInput! + create: SubjectCreateWithoutSpecialistsInput! +} + +input SubjectWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2594,9 +2628,12 @@ input TagCategoryWhereInput { name_not_starts_with: String name_ends_with: String name_not_ends_with: String - labels_every: TagLabelWhereInput - labels_some: TagLabelWhereInput - labels_none: TagLabelWhereInput + tags_every: TagWhereInput + tags_some: TagWhereInput + tags_none: TagWhereInput + specialists_every: UserWhereInput + specialists_some: UserWhereInput + specialists_none: UserWhereInput order: Int order_not: Int order_in: [Int!] @@ -2605,7 +2642,7 @@ input TagCategoryWhereInput { order_lte: Int order_gt: Int order_gte: Int - configuration: ConfigurationWhereInput + category: TagCategoryWhereInput createdAt: DateTime createdAt_not: DateTime createdAt_in: [DateTime!] @@ -2622,153 +2659,100 @@ input TagCategoryWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [TagCategoryWhereInput!] - OR: [TagCategoryWhereInput!] - NOT: [TagCategoryWhereInput!] -} - -input TagCategoryWhereUniqueInput { - id: ID -} - -type TagConnection { - pageInfo: PageInfo! - edges: [TagEdge]! - aggregate: AggregateTag! + AND: [SubjectWhereInput!] + OR: [SubjectWhereInput!] + NOT: [SubjectWhereInput!] } -input TagCreateInput { +input SubjectWhereUniqueInput { id: ID - label: TagLabelCreateOneWithoutTagsInput - node: ZNodeCreateOneWithoutTagsInput! - user: UserCreateOneWithoutTagsInput! -} - -input TagCreateManyWithoutLabelInput { - create: [TagCreateWithoutLabelInput!] - connect: [TagWhereUniqueInput!] -} - -input TagCreateManyWithoutNodeInput { - create: [TagCreateWithoutNodeInput!] - connect: [TagWhereUniqueInput!] } -input TagCreateManyWithoutUserInput { - create: [TagCreateWithoutUserInput!] - connect: [TagWhereUniqueInput!] -} - -input TagCreateWithoutLabelInput { - id: ID - node: ZNodeCreateOneWithoutTagsInput! - user: UserCreateOneWithoutTagsInput! -} - -input TagCreateWithoutNodeInput { - id: ID - label: TagLabelCreateOneWithoutTagsInput - user: UserCreateOneWithoutTagsInput! -} - -input TagCreateWithoutUserInput { - id: ID - label: TagLabelCreateOneWithoutTagsInput - node: ZNodeCreateOneWithoutTagsInput! +type Subscription { + answer(where: AnswerSubscriptionWhereInput): AnswerSubscriptionPayload + configuration(where: ConfigurationSubscriptionWhereInput): ConfigurationSubscriptionPayload + flag(where: FlagSubscriptionWhereInput): FlagSubscriptionPayload + historyAction(where: HistoryActionSubscriptionWhereInput): HistoryActionSubscriptionPayload + question(where: QuestionSubscriptionWhereInput): QuestionSubscriptionPayload + source(where: SourceSubscriptionWhereInput): SourceSubscriptionPayload + subject(where: SubjectSubscriptionWhereInput): SubjectSubscriptionPayload + tag(where: TagSubscriptionWhereInput): TagSubscriptionPayload + tagCategory(where: TagCategorySubscriptionWhereInput): TagCategorySubscriptionPayload + user(where: UserSubscriptionWhereInput): UserSubscriptionPayload + zNode(where: ZNodeSubscriptionWhereInput): ZNodeSubscriptionPayload } -type TagEdge { - node: Tag! - cursor: String! +type Tag { + id: ID! + label: Subject + node: ZNode! + user: User! + createdAt: DateTime! + updatedAt: DateTime! } -type TagLabel { +type TagCategory { id: ID! name: String! - tags( - where: TagWhereInput - orderBy: TagOrderByInput - skip: Int - after: String - before: String - first: Int - last: Int - ): [Tag!] - specialists( - where: UserWhereInput - orderBy: UserOrderByInput + labels( + where: SubjectWhereInput + orderBy: SubjectOrderByInput skip: Int after: String before: String first: Int last: Int - ): [User!] + ): [Subject!] order: Int! - category: TagCategory! + configuration: Configuration! createdAt: DateTime! updatedAt: DateTime! } -type TagLabelConnection { +type TagCategoryConnection { pageInfo: PageInfo! - edges: [TagLabelEdge]! - aggregate: AggregateTagLabel! + edges: [TagCategoryEdge]! + aggregate: AggregateTagCategory! } -input TagLabelCreateInput { +input TagCategoryCreateInput { id: ID name: String! - tags: TagCreateManyWithoutLabelInput - specialists: UserCreateManyWithoutSpecialtiesInput + labels: SubjectCreateManyWithoutCategoryInput order: Int! - category: TagCategoryCreateOneWithoutLabelsInput! -} - -input TagLabelCreateManyWithoutCategoryInput { - create: [TagLabelCreateWithoutCategoryInput!] - connect: [TagLabelWhereUniqueInput!] -} - -input TagLabelCreateManyWithoutSpecialistsInput { - create: [TagLabelCreateWithoutSpecialistsInput!] - connect: [TagLabelWhereUniqueInput!] + configuration: ConfigurationCreateOneWithoutTagCategoriesInput! } -input TagLabelCreateOneWithoutTagsInput { - create: TagLabelCreateWithoutTagsInput - connect: TagLabelWhereUniqueInput +input TagCategoryCreateManyWithoutConfigurationInput { + create: [TagCategoryCreateWithoutConfigurationInput!] + connect: [TagCategoryWhereUniqueInput!] } -input TagLabelCreateWithoutCategoryInput { - id: ID - name: String! - tags: TagCreateManyWithoutLabelInput - specialists: UserCreateManyWithoutSpecialtiesInput - order: Int! +input TagCategoryCreateOneWithoutLabelsInput { + create: TagCategoryCreateWithoutLabelsInput + connect: TagCategoryWhereUniqueInput } -input TagLabelCreateWithoutSpecialistsInput { +input TagCategoryCreateWithoutConfigurationInput { id: ID name: String! - tags: TagCreateManyWithoutLabelInput + labels: SubjectCreateManyWithoutCategoryInput order: Int! - category: TagCategoryCreateOneWithoutLabelsInput! } -input TagLabelCreateWithoutTagsInput { +input TagCategoryCreateWithoutLabelsInput { id: ID name: String! - specialists: UserCreateManyWithoutSpecialtiesInput order: Int! - category: TagCategoryCreateOneWithoutLabelsInput! + configuration: ConfigurationCreateOneWithoutTagCategoriesInput! } -type TagLabelEdge { - node: TagLabel! +type TagCategoryEdge { + node: TagCategory! cursor: String! } -enum TagLabelOrderByInput { +enum TagCategoryOrderByInput { id_ASC id_DESC name_ASC @@ -2781,7 +2765,7 @@ enum TagLabelOrderByInput { updatedAt_DESC } -type TagLabelPreviousValues { +type TagCategoryPreviousValues { id: ID! name: String! order: Int! @@ -2789,7 +2773,7 @@ type TagLabelPreviousValues { updatedAt: DateTime! } -input TagLabelScalarWhereInput { +input TagCategoryScalarWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2842,134 +2826,99 @@ input TagLabelScalarWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [TagLabelScalarWhereInput!] - OR: [TagLabelScalarWhereInput!] - NOT: [TagLabelScalarWhereInput!] + AND: [TagCategoryScalarWhereInput!] + OR: [TagCategoryScalarWhereInput!] + NOT: [TagCategoryScalarWhereInput!] } -type TagLabelSubscriptionPayload { +type TagCategorySubscriptionPayload { mutation: MutationType! - node: TagLabel + node: TagCategory updatedFields: [String!] - previousValues: TagLabelPreviousValues + previousValues: TagCategoryPreviousValues } -input TagLabelSubscriptionWhereInput { +input TagCategorySubscriptionWhereInput { mutation_in: [MutationType!] updatedFields_contains: String updatedFields_contains_every: [String!] updatedFields_contains_some: [String!] - node: TagLabelWhereInput - AND: [TagLabelSubscriptionWhereInput!] - OR: [TagLabelSubscriptionWhereInput!] - NOT: [TagLabelSubscriptionWhereInput!] + node: TagCategoryWhereInput + AND: [TagCategorySubscriptionWhereInput!] + OR: [TagCategorySubscriptionWhereInput!] + NOT: [TagCategorySubscriptionWhereInput!] } -input TagLabelUpdateInput { +input TagCategoryUpdateInput { name: String - tags: TagUpdateManyWithoutLabelInput - specialists: UserUpdateManyWithoutSpecialtiesInput + labels: SubjectUpdateManyWithoutCategoryInput order: Int - category: TagCategoryUpdateOneRequiredWithoutLabelsInput + configuration: ConfigurationUpdateOneRequiredWithoutTagCategoriesInput } -input TagLabelUpdateManyDataInput { +input TagCategoryUpdateManyDataInput { name: String order: Int } -input TagLabelUpdateManyMutationInput { +input TagCategoryUpdateManyMutationInput { name: String order: Int } -input TagLabelUpdateManyWithoutCategoryInput { - create: [TagLabelCreateWithoutCategoryInput!] - delete: [TagLabelWhereUniqueInput!] - connect: [TagLabelWhereUniqueInput!] - set: [TagLabelWhereUniqueInput!] - disconnect: [TagLabelWhereUniqueInput!] - update: [TagLabelUpdateWithWhereUniqueWithoutCategoryInput!] - upsert: [TagLabelUpsertWithWhereUniqueWithoutCategoryInput!] - deleteMany: [TagLabelScalarWhereInput!] - updateMany: [TagLabelUpdateManyWithWhereNestedInput!] -} - -input TagLabelUpdateManyWithoutSpecialistsInput { - create: [TagLabelCreateWithoutSpecialistsInput!] - delete: [TagLabelWhereUniqueInput!] - connect: [TagLabelWhereUniqueInput!] - set: [TagLabelWhereUniqueInput!] - disconnect: [TagLabelWhereUniqueInput!] - update: [TagLabelUpdateWithWhereUniqueWithoutSpecialistsInput!] - upsert: [TagLabelUpsertWithWhereUniqueWithoutSpecialistsInput!] - deleteMany: [TagLabelScalarWhereInput!] - updateMany: [TagLabelUpdateManyWithWhereNestedInput!] -} - -input TagLabelUpdateManyWithWhereNestedInput { - where: TagLabelScalarWhereInput! - data: TagLabelUpdateManyDataInput! +input TagCategoryUpdateManyWithoutConfigurationInput { + create: [TagCategoryCreateWithoutConfigurationInput!] + delete: [TagCategoryWhereUniqueInput!] + connect: [TagCategoryWhereUniqueInput!] + set: [TagCategoryWhereUniqueInput!] + disconnect: [TagCategoryWhereUniqueInput!] + update: [TagCategoryUpdateWithWhereUniqueWithoutConfigurationInput!] + upsert: [TagCategoryUpsertWithWhereUniqueWithoutConfigurationInput!] + deleteMany: [TagCategoryScalarWhereInput!] + updateMany: [TagCategoryUpdateManyWithWhereNestedInput!] } -input TagLabelUpdateOneWithoutTagsInput { - create: TagLabelCreateWithoutTagsInput - update: TagLabelUpdateWithoutTagsDataInput - upsert: TagLabelUpsertWithoutTagsInput - delete: Boolean - disconnect: Boolean - connect: TagLabelWhereUniqueInput +input TagCategoryUpdateManyWithWhereNestedInput { + where: TagCategoryScalarWhereInput! + data: TagCategoryUpdateManyDataInput! } -input TagLabelUpdateWithoutCategoryDataInput { - name: String - tags: TagUpdateManyWithoutLabelInput - specialists: UserUpdateManyWithoutSpecialtiesInput - order: Int +input TagCategoryUpdateOneRequiredWithoutLabelsInput { + create: TagCategoryCreateWithoutLabelsInput + update: TagCategoryUpdateWithoutLabelsDataInput + upsert: TagCategoryUpsertWithoutLabelsInput + connect: TagCategoryWhereUniqueInput } -input TagLabelUpdateWithoutSpecialistsDataInput { +input TagCategoryUpdateWithoutConfigurationDataInput { name: String - tags: TagUpdateManyWithoutLabelInput + labels: SubjectUpdateManyWithoutCategoryInput order: Int - category: TagCategoryUpdateOneRequiredWithoutLabelsInput } -input TagLabelUpdateWithoutTagsDataInput { +input TagCategoryUpdateWithoutLabelsDataInput { name: String - specialists: UserUpdateManyWithoutSpecialtiesInput order: Int - category: TagCategoryUpdateOneRequiredWithoutLabelsInput -} - -input TagLabelUpdateWithWhereUniqueWithoutCategoryInput { - where: TagLabelWhereUniqueInput! - data: TagLabelUpdateWithoutCategoryDataInput! -} - -input TagLabelUpdateWithWhereUniqueWithoutSpecialistsInput { - where: TagLabelWhereUniqueInput! - data: TagLabelUpdateWithoutSpecialistsDataInput! + configuration: ConfigurationUpdateOneRequiredWithoutTagCategoriesInput } -input TagLabelUpsertWithoutTagsInput { - update: TagLabelUpdateWithoutTagsDataInput! - create: TagLabelCreateWithoutTagsInput! +input TagCategoryUpdateWithWhereUniqueWithoutConfigurationInput { + where: TagCategoryWhereUniqueInput! + data: TagCategoryUpdateWithoutConfigurationDataInput! } -input TagLabelUpsertWithWhereUniqueWithoutCategoryInput { - where: TagLabelWhereUniqueInput! - update: TagLabelUpdateWithoutCategoryDataInput! - create: TagLabelCreateWithoutCategoryInput! +input TagCategoryUpsertWithoutLabelsInput { + update: TagCategoryUpdateWithoutLabelsDataInput! + create: TagCategoryCreateWithoutLabelsInput! } -input TagLabelUpsertWithWhereUniqueWithoutSpecialistsInput { - where: TagLabelWhereUniqueInput! - update: TagLabelUpdateWithoutSpecialistsDataInput! - create: TagLabelCreateWithoutSpecialistsInput! +input TagCategoryUpsertWithWhereUniqueWithoutConfigurationInput { + where: TagCategoryWhereUniqueInput! + update: TagCategoryUpdateWithoutConfigurationDataInput! + create: TagCategoryCreateWithoutConfigurationInput! } -input TagLabelWhereInput { +input TagCategoryWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2998,12 +2947,9 @@ input TagLabelWhereInput { name_not_starts_with: String name_ends_with: String name_not_ends_with: String - tags_every: TagWhereInput - tags_some: TagWhereInput - tags_none: TagWhereInput - specialists_every: UserWhereInput - specialists_some: UserWhereInput - specialists_none: UserWhereInput + labels_every: SubjectWhereInput + labels_some: SubjectWhereInput + labels_none: SubjectWhereInput order: Int order_not: Int order_in: [Int!] @@ -3012,7 +2958,7 @@ input TagLabelWhereInput { order_lte: Int order_gt: Int order_gte: Int - category: TagCategoryWhereInput + configuration: ConfigurationWhereInput createdAt: DateTime createdAt_not: DateTime createdAt_in: [DateTime!] @@ -3029,13 +2975,64 @@ input TagLabelWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [TagLabelWhereInput!] - OR: [TagLabelWhereInput!] - NOT: [TagLabelWhereInput!] + AND: [TagCategoryWhereInput!] + OR: [TagCategoryWhereInput!] + NOT: [TagCategoryWhereInput!] +} + +input TagCategoryWhereUniqueInput { + id: ID +} + +type TagConnection { + pageInfo: PageInfo! + edges: [TagEdge]! + aggregate: AggregateTag! +} + +input TagCreateInput { + id: ID + label: SubjectCreateOneWithoutTagsInput + node: ZNodeCreateOneWithoutTagsInput! + user: UserCreateOneWithoutTagsInput! +} + +input TagCreateManyWithoutLabelInput { + create: [TagCreateWithoutLabelInput!] + connect: [TagWhereUniqueInput!] +} + +input TagCreateManyWithoutNodeInput { + create: [TagCreateWithoutNodeInput!] + connect: [TagWhereUniqueInput!] +} + +input TagCreateManyWithoutUserInput { + create: [TagCreateWithoutUserInput!] + connect: [TagWhereUniqueInput!] +} + +input TagCreateWithoutLabelInput { + id: ID + node: ZNodeCreateOneWithoutTagsInput! + user: UserCreateOneWithoutTagsInput! } -input TagLabelWhereUniqueInput { +input TagCreateWithoutNodeInput { + id: ID + label: SubjectCreateOneWithoutTagsInput + user: UserCreateOneWithoutTagsInput! +} + +input TagCreateWithoutUserInput { id: ID + label: SubjectCreateOneWithoutTagsInput + node: ZNodeCreateOneWithoutTagsInput! +} + +type TagEdge { + node: Tag! + cursor: String! } enum TagOrderByInput { @@ -3108,7 +3105,7 @@ input TagSubscriptionWhereInput { } input TagUpdateInput { - label: TagLabelUpdateOneWithoutTagsInput + label: SubjectUpdateOneWithoutTagsInput node: ZNodeUpdateOneRequiredWithoutTagsInput user: UserUpdateOneRequiredWithoutTagsInput } @@ -3152,12 +3149,12 @@ input TagUpdateWithoutLabelDataInput { } input TagUpdateWithoutNodeDataInput { - label: TagLabelUpdateOneWithoutTagsInput + label: SubjectUpdateOneWithoutTagsInput user: UserUpdateOneRequiredWithoutTagsInput } input TagUpdateWithoutUserDataInput { - label: TagLabelUpdateOneWithoutTagsInput + label: SubjectUpdateOneWithoutTagsInput node: ZNodeUpdateOneRequiredWithoutTagsInput } @@ -3209,7 +3206,7 @@ input TagWhereInput { id_not_starts_with: ID id_ends_with: ID id_not_ends_with: ID - label: TagLabelWhereInput + label: SubjectWhereInput node: ZNodeWhereInput user: UserWhereInput createdAt: DateTime @@ -3283,14 +3280,14 @@ type User { last: Int ): [Tag!] specialties( - where: TagLabelWhereInput - orderBy: TagLabelOrderByInput + where: SubjectWhereInput + orderBy: SubjectOrderByInput skip: Int after: String before: String first: Int last: Int - ): [TagLabel!] + ): [Subject!] history( where: HistoryActionWhereInput orderBy: HistoryActionOrderByInput @@ -3323,7 +3320,7 @@ input UserCreateInput { answers: AnswerCreateManyWithoutUserInput flags: FlagCreateManyWithoutUserInput tags: TagCreateManyWithoutUserInput - specialties: TagLabelCreateManyWithoutSpecialistsInput + specialties: SubjectCreateManyWithoutSpecialistsInput history: HistoryActionCreateManyWithoutUserInput } @@ -3369,7 +3366,7 @@ input UserCreateWithoutAnswersInput { questions: QuestionCreateManyWithoutUserInput flags: FlagCreateManyWithoutUserInput tags: TagCreateManyWithoutUserInput - specialties: TagLabelCreateManyWithoutSpecialistsInput + specialties: SubjectCreateManyWithoutSpecialistsInput history: HistoryActionCreateManyWithoutUserInput } @@ -3385,7 +3382,7 @@ input UserCreateWithoutFlagsInput { questions: QuestionCreateManyWithoutUserInput answers: AnswerCreateManyWithoutUserInput tags: TagCreateManyWithoutUserInput - specialties: TagLabelCreateManyWithoutSpecialistsInput + specialties: SubjectCreateManyWithoutSpecialistsInput history: HistoryActionCreateManyWithoutUserInput } @@ -3402,7 +3399,7 @@ input UserCreateWithoutHistoryInput { answers: AnswerCreateManyWithoutUserInput flags: FlagCreateManyWithoutUserInput tags: TagCreateManyWithoutUserInput - specialties: TagLabelCreateManyWithoutSpecialistsInput + specialties: SubjectCreateManyWithoutSpecialistsInput } input UserCreateWithoutQuestionsInput { @@ -3417,7 +3414,7 @@ input UserCreateWithoutQuestionsInput { answers: AnswerCreateManyWithoutUserInput flags: FlagCreateManyWithoutUserInput tags: TagCreateManyWithoutUserInput - specialties: TagLabelCreateManyWithoutSpecialistsInput + specialties: SubjectCreateManyWithoutSpecialistsInput history: HistoryActionCreateManyWithoutUserInput } @@ -3449,7 +3446,7 @@ input UserCreateWithoutTagsInput { questions: QuestionCreateManyWithoutUserInput answers: AnswerCreateManyWithoutUserInput flags: FlagCreateManyWithoutUserInput - specialties: TagLabelCreateManyWithoutSpecialistsInput + specialties: SubjectCreateManyWithoutSpecialistsInput history: HistoryActionCreateManyWithoutUserInput } @@ -3646,7 +3643,7 @@ input UserUpdateInput { answers: AnswerUpdateManyWithoutUserInput flags: FlagUpdateManyWithoutUserInput tags: TagUpdateManyWithoutUserInput - specialties: TagLabelUpdateManyWithoutSpecialistsInput + specialties: SubjectUpdateManyWithoutSpecialistsInput history: HistoryActionUpdateManyWithoutUserInput } @@ -3733,7 +3730,7 @@ input UserUpdateWithoutAnswersDataInput { questions: QuestionUpdateManyWithoutUserInput flags: FlagUpdateManyWithoutUserInput tags: TagUpdateManyWithoutUserInput - specialties: TagLabelUpdateManyWithoutSpecialistsInput + specialties: SubjectUpdateManyWithoutSpecialistsInput history: HistoryActionUpdateManyWithoutUserInput } @@ -3748,7 +3745,7 @@ input UserUpdateWithoutFlagsDataInput { questions: QuestionUpdateManyWithoutUserInput answers: AnswerUpdateManyWithoutUserInput tags: TagUpdateManyWithoutUserInput - specialties: TagLabelUpdateManyWithoutSpecialistsInput + specialties: SubjectUpdateManyWithoutSpecialistsInput history: HistoryActionUpdateManyWithoutUserInput } @@ -3764,7 +3761,7 @@ input UserUpdateWithoutHistoryDataInput { answers: AnswerUpdateManyWithoutUserInput flags: FlagUpdateManyWithoutUserInput tags: TagUpdateManyWithoutUserInput - specialties: TagLabelUpdateManyWithoutSpecialistsInput + specialties: SubjectUpdateManyWithoutSpecialistsInput } input UserUpdateWithoutQuestionsDataInput { @@ -3778,7 +3775,7 @@ input UserUpdateWithoutQuestionsDataInput { answers: AnswerUpdateManyWithoutUserInput flags: FlagUpdateManyWithoutUserInput tags: TagUpdateManyWithoutUserInput - specialties: TagLabelUpdateManyWithoutSpecialistsInput + specialties: SubjectUpdateManyWithoutSpecialistsInput history: HistoryActionUpdateManyWithoutUserInput } @@ -3808,7 +3805,7 @@ input UserUpdateWithoutTagsDataInput { questions: QuestionUpdateManyWithoutUserInput answers: AnswerUpdateManyWithoutUserInput flags: FlagUpdateManyWithoutUserInput - specialties: TagLabelUpdateManyWithoutSpecialistsInput + specialties: SubjectUpdateManyWithoutSpecialistsInput history: HistoryActionUpdateManyWithoutUserInput } @@ -3961,9 +3958,9 @@ input UserWhereInput { tags_every: TagWhereInput tags_some: TagWhereInput tags_none: TagWhereInput - specialties_every: TagLabelWhereInput - specialties_some: TagLabelWhereInput - specialties_none: TagLabelWhereInput + specialties_every: SubjectWhereInput + specialties_some: SubjectWhereInput + specialties_none: SubjectWhereInput history_every: HistoryActionWhereInput history_some: HistoryActionWhereInput history_none: HistoryActionWhereInput diff --git a/server/src/helpers/diffTags.js b/server/src/helpers/diffTags.js index 2c01ac2da..5b6dd08f4 100644 --- a/server/src/helpers/diffTags.js +++ b/server/src/helpers/diffTags.js @@ -83,7 +83,7 @@ const diffTags = (ctx, oldCats, newCats, confId) => { promises.push( Promise.all( labelsToCreate.map(label => - ctx.prisma.mutation.createTagLabel({ + ctx.prisma.mutation.createSubject({ data: { name: label.name, order: label.order, @@ -123,7 +123,7 @@ const diffTags = (ctx, oldCats, newCats, confId) => { promises.push( Promise.all( labelsToUpdate.map(label => - ctx.prisma.mutation.updateTagLabel({ + ctx.prisma.mutation.updateSubject({ where: { id: label.id }, data: { name: label.name, order: label.order } }) @@ -141,7 +141,7 @@ const diffTags = (ctx, oldCats, newCats, confId) => { algoliaChanges.deleted.push(...labelsToDelete.map(l => l.name)) promises.push( Promise.all( - labelsToDelete.map(label => ctx.prisma.mutation.deleteTagLabel({ where: { id: label.id } })) + labelsToDelete.map(label => ctx.prisma.mutation.deleteSubject({ where: { id: label.id } })) ) ) diff --git a/server/src/resolvers/question.js b/server/src/resolvers/question.js index 54e1455b5..701ef214a 100644 --- a/server/src/resolvers/question.js +++ b/server/src/resolvers/question.js @@ -2,7 +2,7 @@ const { history, ctxUser, slugify, deleteCertifedFlagIfNoLongerApplicable } = re const { algolia, slack } = require('../integrations') // TMP_TAGS -const confTagLabels = ctx => +const confSubjects = ctx => ctx.prisma._meta.configuration.tagCategories.reduce((acc, cat) => acc.concat(cat.labels), []) module.exports = { @@ -11,7 +11,7 @@ module.exports = { }, Mutation: { createQuestionAndTags: async (_, { title, tags }, ctx, info) => { - const tagLabels = confTagLabels(ctx) + const subjects = confSubjects(ctx) const node = await ctx.prisma.mutation.createZNode( { @@ -25,9 +25,9 @@ module.exports = { }, tags: { create: tags - .filter(tagLabelId => !!tagLabels.find(label => label.id === tagLabelId)) - .map(tagLabelId => ({ - label: { connect: { id: tagLabelId } }, + .filter(subjectId => !!subjects.find(label => label.id === subjectId)) + .map(subjectId => ({ + label: { connect: { id: subjectId } }, user: { connect: { id: ctxUser(ctx).id } } })) }, @@ -54,7 +54,7 @@ module.exports = { model: 'Question', meta: { title, - tags: tags.map(id => tagLabels.find(label => label.id === id).name) + tags: tags.map(id => subjects.find(label => label.id === id).name) }, nodeId: node.id }) @@ -65,7 +65,7 @@ module.exports = { return ctx.prisma.query.question({ where: { id: node.question.id } }, info) }, updateQuestionAndTags: async (_, { id, title, previousTitle, tags }, ctx, info) => { - const tagLabels = confTagLabels(ctx) + const subjects = confSubjects(ctx) const node = ( await ctx.prisma.query.question( @@ -113,7 +113,7 @@ module.exports = { const tagsToRemove = oldLabels.filter(oldLabel => !newLabels.includes(oldLabel)) const mutationsToAdd = tagsToAdd - .filter(labelId => tagLabels.find(label => label.id === labelId)) + .filter(labelId => subjects.find(label => label.id === labelId)) .map(labelId => ctx.prisma.mutation.createTag({ data: { @@ -139,8 +139,8 @@ module.exports = { const meta = { tagsChanges: { - added: tagsToAdd.map(id => tagLabels.find(label => label.id === id).name), - removed: tagsToRemove.map(id => tagLabels.find(label => label.id === id).name) + added: tagsToAdd.map(id => subjects.find(label => label.id === id).name), + removed: tagsToRemove.map(id => subjects.find(label => label.id === id).name) } } diff --git a/server/src/schema.graphql b/server/src/schema.graphql index d7eeec8f7..959794de4 100644 --- a/server/src/schema.graphql +++ b/server/src/schema.graphql @@ -1,4 +1,4 @@ -# import ZNode, Question, Answer, Source, Flag, TagLabel, TagCategory, HistoryAction, BugReporting from './generated/prisma.graphql' +# import ZNode, Question, Answer, Source, Flag, Subject, TagCategory, HistoryAction, BugReporting from './generated/prisma.graphql' # import ZNodeOrderByInput, ZNodeConnection, ZNodeWhereUniqueInput from './generated/prisma.graphql' # import HistoryActionWhereInput from './generated/prisma.graphql' @@ -90,7 +90,7 @@ type User { email: String picture: String - specialties: [TagLabel!] + specialties: [Subject!] } type Configuration { From 940a4817d6330faf614707194bdee47dec826c2e Mon Sep 17 00:00:00 2001 From: Thibaud Brault Date: Thu, 8 Jun 2023 16:27:19 +0200 Subject: [PATCH 2/3] :card_file_box: rename some relations according to the pr comments --- server/prisma/datamodel.graphql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/prisma/datamodel.graphql b/server/prisma/datamodel.graphql index 5fc33ce95..a2c103397 100644 --- a/server/prisma/datamodel.graphql +++ b/server/prisma/datamodel.graphql @@ -68,7 +68,7 @@ type Flag { type Tag { id: ID! @unique @id - label: Subject @relation(name: "Tags", link: TABLE) + label: Subject @relation(name: "TagSubject", link: TABLE) node: ZNode! @relation(name: "NodeTags") user: User! @relation(name: "UserTags", link: TABLE) @@ -81,11 +81,11 @@ type Subject { id: ID! @unique @id name: String! - tags: [Tag!]! @relation(name: "Tags", onDelete: CASCADE) + tags: [Tag!]! @relation(name: "TagSubject", onDelete: CASCADE) specialists: [User!]! @relation(name: "UserSpecialties", link: TABLE) order: Int! - category: TagCategory! @relation(name: "SubjectsCategory", link: TABLE) + category: TagCategory! @relation(name: "SubjectCategory", link: TABLE) createdAt: DateTime! @createdAt updatedAt: DateTime! @updatedAt @@ -95,7 +95,7 @@ type TagCategory { id: ID! @unique @id name: String! - labels: [Subject!]! @relation(name: "SubjectsCategory", onDelete: CASCADE) + labels: [Subject!]! @relation(name: "SubjectCategory", onDelete: CASCADE) order: Int! configuration: Configuration! @relation(name: "ConfigurationTags", link: TABLE) From 10d530d30e12c113a9925d9047060ea31ce8528e Mon Sep 17 00:00:00 2001 From: Thibaud Brault Date: Thu, 8 Jun 2023 17:26:19 +0200 Subject: [PATCH 3/3] :construction: rename types --- client/src/components/TagPicker/TagPicker.jsx | 4 +- client/src/components/UsersList/UsersList.jsx | 2 +- client/src/components/UsersList/queries.js | 2 +- .../Home/components/Searchbar/Searchbar.jsx | 2 +- client/src/scenes/Settings/Settings.jsx | 2 +- client/src/scenes/Settings/helpers.js | 2 +- client/src/scenes/Settings/queries.js | 6 +- client/src/scenes/Settings/scenes/Tags.jsx | 2 +- e2e/client.test.js | 4 +- server/prisma/datamodel.graphql | 6 +- server/scripts/prisma_new_service/index.js | 2 +- server/scripts/tmp_tag_resync/part1.js | 2 +- server/src/endpoints/configuration.js | 4 +- server/src/generated/prisma.graphql | 609 +++++++++--------- server/src/helpers/diffTags.js | 6 +- server/src/middlewares/auth.js | 2 +- server/src/middlewares/configuration.js | 2 +- server/src/resolvers/configuration.js | 13 +- server/src/resolvers/question.js | 4 +- server/src/schema.graphql | 6 +- 20 files changed, 345 insertions(+), 337 deletions(-) diff --git a/client/src/components/TagPicker/TagPicker.jsx b/client/src/components/TagPicker/TagPicker.jsx index d36f71028..0b25a89ea 100644 --- a/client/src/components/TagPicker/TagPicker.jsx +++ b/client/src/components/TagPicker/TagPicker.jsx @@ -16,7 +16,7 @@ const TagPicker = ({ label, icon, tags, onChange }) => { const [opened, setOpened] = useState(false) const ref = useClickOutside(() => setOpened(false)) - const tagCategories = conf ? conf.tagCategories : [] + const subjectCategories = conf ? conf.subjectCategories : [] return (
@@ -45,7 +45,7 @@ const TagPicker = ({ label, icon, tags, onChange }) => { />
- {sortBy(tagCategories, ['order']).map(category => ( + {sortBy(subjectCategories, ['order']).map(category => (
{sortBy(category.labels, ['order']).map(label => { const isSelected = !!tags.find(t => t.id === label.id) diff --git a/client/src/components/UsersList/UsersList.jsx b/client/src/components/UsersList/UsersList.jsx index e80588647..aa2f53451 100644 --- a/client/src/components/UsersList/UsersList.jsx +++ b/client/src/components/UsersList/UsersList.jsx @@ -18,7 +18,7 @@ const UsersList = () => { const users = usersData ? usersData.users : [] const specialists = usersData ? usersData.users.filter(user => user.specialties.length > 0) : [] const services = servicesData - ? servicesData.configuration.tagCategories.find(category => category.name === 'services') + ? servicesData.configuration.subjectCategories.find(category => category.name === 'services') ?.labels : null diff --git a/client/src/components/UsersList/queries.js b/client/src/components/UsersList/queries.js index e9a956d2e..e92076fdc 100644 --- a/client/src/components/UsersList/queries.js +++ b/client/src/components/UsersList/queries.js @@ -4,7 +4,7 @@ export const GET_TAG_CATEGORIES = gql` query { configuration { id - tagCategories { + subjectCategories { id name labels { diff --git a/client/src/scenes/Home/components/Searchbar/Searchbar.jsx b/client/src/scenes/Home/components/Searchbar/Searchbar.jsx index 277bd8160..8f38a0324 100644 --- a/client/src/scenes/Home/components/Searchbar/Searchbar.jsx +++ b/client/src/scenes/Home/components/Searchbar/Searchbar.jsx @@ -15,7 +15,7 @@ const Searchbar = ({ text, tags, loading, onTextChange, onTagsChange }) => { const subjects = tags .map(tag => - conf.tagCategories + conf.subjectCategories .reduce((acc, cat) => acc.concat(cat.labels), []) .find(label => label.name === tag) ) diff --git a/client/src/scenes/Settings/Settings.jsx b/client/src/scenes/Settings/Settings.jsx index dcb53b2a1..0bb85a05e 100644 --- a/client/src/scenes/Settings/Settings.jsx +++ b/client/src/scenes/Settings/Settings.jsx @@ -55,7 +55,7 @@ const Settings = ({ configuration: conf }) => { mutate({ variables: { title: state.title, - tagCategories: serializeTags(state.tagCategories), + subjectCategories: serializeTags(state.subjectCategories), algoliaSynonyms: listToSynonyms(state.synonyms), workplaceSharing: state.workplaceSharing, authorizedDomains: state.authorizedDomains diff --git a/client/src/scenes/Settings/helpers.js b/client/src/scenes/Settings/helpers.js index c12b0aa32..b54914b28 100644 --- a/client/src/scenes/Settings/helpers.js +++ b/client/src/scenes/Settings/helpers.js @@ -18,7 +18,7 @@ export const reducer = (state, action) => { case 'change_slack_commandkey': return { ...state, slackCommandKey: action.data } case 'change_tags': - return { ...state, tagCategories: action.data } + return { ...state, subjectCategories: action.data } default: return { ...state, diff --git a/client/src/scenes/Settings/queries.js b/client/src/scenes/Settings/queries.js index 0b333e59f..47f18b47d 100644 --- a/client/src/scenes/Settings/queries.js +++ b/client/src/scenes/Settings/queries.js @@ -3,7 +3,7 @@ import gql from 'graphql-tag' const CONFIGURATION_FRAGMENT = ` id title - tagCategories { + subjectCategories { id order name @@ -32,7 +32,7 @@ export const GET_CONFIGURATION = gql` export const UPDATE_CONFIGURATION = gql` mutation updateConfiguration( $title: String! - $tagCategories: Json! + $subjectCategories: Json! $algoliaSynonyms: Json! $workplaceSharing: Boolean! $authorizedDomains: [String!]! @@ -41,7 +41,7 @@ export const UPDATE_CONFIGURATION = gql` ) { updateConfiguration( title: $title - tagCategories: $tagCategories + subjectCategories: $subjectCategories algoliaSynonyms: $algoliaSynonyms workplaceSharing: $workplaceSharing authorizedDomains: $authorizedDomains diff --git a/client/src/scenes/Settings/scenes/Tags.jsx b/client/src/scenes/Settings/scenes/Tags.jsx index dea2ad84c..5baaec7d5 100644 --- a/client/src/scenes/Settings/scenes/Tags.jsx +++ b/client/src/scenes/Settings/scenes/Tags.jsx @@ -11,7 +11,7 @@ const Tags = ({ state, onTagsChange }) => { return ( - + ) } diff --git a/e2e/client.test.js b/e2e/client.test.js index 35d95c91b..2b61105fc 100644 --- a/e2e/client.test.js +++ b/e2e/client.test.js @@ -56,7 +56,7 @@ const upsertConfig = /* GraphQL */ `mutation UpsertConfig{ algoliaApiKey: "${process.env.ALGOLIA_API_KEY_ALL}" auth0Domain: "${process.env.AUTH0_DOMAIN}" auth0ClientId: "${process.env.AUTH0_CLIENT_ID}" - tagCategories: { + subjectCategories: { create: [ { name: "services", @@ -113,7 +113,7 @@ const upsertConfig = /* GraphQL */ `mutation UpsertConfig{ mailgunDomain mailgunApiKey slackChannelHook - tagCategories { + subjectCategories { order name labels { diff --git a/server/prisma/datamodel.graphql b/server/prisma/datamodel.graphql index a2c103397..54d8cbbae 100644 --- a/server/prisma/datamodel.graphql +++ b/server/prisma/datamodel.graphql @@ -85,13 +85,13 @@ type Subject { specialists: [User!]! @relation(name: "UserSpecialties", link: TABLE) order: Int! - category: TagCategory! @relation(name: "SubjectCategory", link: TABLE) + category: SubjectCategory! @relation(name: "TagLabelsCategory", link: TABLE) createdAt: DateTime! @createdAt updatedAt: DateTime! @updatedAt } -type TagCategory { +type SubjectCategory { id: ID! @unique @id name: String! @@ -166,7 +166,7 @@ type Configuration { slackCommandKey: String tags: Json - tagCategories: [TagCategory!]! @relation(name: "ConfigurationTags", onDelete: CASCADE) + subjectCategories: [SubjectCategory!]! @relation(name: "ConfigurationTags", onDelete: CASCADE) workplaceSharing: Boolean @default(value: false) diff --git a/server/scripts/prisma_new_service/index.js b/server/scripts/prisma_new_service/index.js index b7e2bbfaf..e3cb736f2 100644 --- a/server/scripts/prisma_new_service/index.js +++ b/server/scripts/prisma_new_service/index.js @@ -62,7 +62,7 @@ const main = async () => { algoliaSynonyms: "{\"objectId\": \"testSynonyms\", \"type\": \"synonym\", \"synonyms\": [\"hello\", \"hi\"]}" mailgunDomain: "${MAILGUN_DOMAIN || ''}" mailgunApiKey: "${MAILGUN_API_KEY || ''}" - tagCategories: { + subjectCategories: { create: [ { name: "services", diff --git a/server/scripts/tmp_tag_resync/part1.js b/server/scripts/tmp_tag_resync/part1.js index 6513a2a98..56ae5e051 100644 --- a/server/scripts/tmp_tag_resync/part1.js +++ b/server/scripts/tmp_tag_resync/part1.js @@ -21,7 +21,7 @@ const resync = async (name, stage) => { const tagsCategories = await Promise.all( categories.map(([name, tags], order) => - prisma.mutation.createTagCategory( + prisma.mutation.createSubjectCategory( { data: { name, diff --git a/server/src/endpoints/configuration.js b/server/src/endpoints/configuration.js index d19ed312b..5db842977 100644 --- a/server/src/endpoints/configuration.js +++ b/server/src/endpoints/configuration.js @@ -14,7 +14,7 @@ const configurationEndpoint = multiTenant => async (req, res) => title, auth0Domain, auth0ClientId, - tagCategories, + subjectCategories, workplaceSharing, bugReporting } = multiTenant.current(req)._meta.configuration @@ -24,7 +24,7 @@ const configurationEndpoint = multiTenant => async (req, res) => title, auth0Domain, auth0ClientId, - tagCategories, + subjectCategories, workplaceSharing, bugReporting }) diff --git a/server/src/generated/prisma.graphql b/server/src/generated/prisma.graphql index 04e384400..e0594d4b6 100644 --- a/server/src/generated/prisma.graphql +++ b/server/src/generated/prisma.graphql @@ -26,11 +26,11 @@ type AggregateSubject { count: Int! } -type AggregateTag { +type AggregateSubjectCategory { count: Int! } -type AggregateTagCategory { +type AggregateTag { count: Int! } @@ -371,15 +371,15 @@ type Configuration { slackChannelHook: String slackCommandKey: String tags: Json - tagCategories( - where: TagCategoryWhereInput - orderBy: TagCategoryOrderByInput + subjectCategories( + where: SubjectCategoryWhereInput + orderBy: SubjectCategoryOrderByInput skip: Int after: String before: String first: Int last: Int - ): [TagCategory!] + ): [SubjectCategory!] workplaceSharing: Boolean bugReporting: BugReporting createdAt: DateTime! @@ -411,17 +411,17 @@ input ConfigurationCreateInput { slackChannelHook: String slackCommandKey: String tags: Json - tagCategories: TagCategoryCreateManyWithoutConfigurationInput + subjectCategories: SubjectCategoryCreateManyWithoutConfigurationInput workplaceSharing: Boolean bugReporting: BugReporting } -input ConfigurationCreateOneWithoutTagCategoriesInput { - create: ConfigurationCreateWithoutTagCategoriesInput +input ConfigurationCreateOneWithoutSubjectCategoriesInput { + create: ConfigurationCreateWithoutSubjectCategoriesInput connect: ConfigurationWhereUniqueInput } -input ConfigurationCreateWithoutTagCategoriesInput { +input ConfigurationCreateWithoutSubjectCategoriesInput { id: ID name: String! title: String @@ -539,7 +539,7 @@ input ConfigurationUpdateInput { slackChannelHook: String slackCommandKey: String tags: Json - tagCategories: TagCategoryUpdateManyWithoutConfigurationInput + subjectCategories: SubjectCategoryUpdateManyWithoutConfigurationInput workplaceSharing: Boolean bugReporting: BugReporting } @@ -562,14 +562,14 @@ input ConfigurationUpdateManyMutationInput { bugReporting: BugReporting } -input ConfigurationUpdateOneRequiredWithoutTagCategoriesInput { - create: ConfigurationCreateWithoutTagCategoriesInput - update: ConfigurationUpdateWithoutTagCategoriesDataInput - upsert: ConfigurationUpsertWithoutTagCategoriesInput +input ConfigurationUpdateOneRequiredWithoutSubjectCategoriesInput { + create: ConfigurationCreateWithoutSubjectCategoriesInput + update: ConfigurationUpdateWithoutSubjectCategoriesDataInput + upsert: ConfigurationUpsertWithoutSubjectCategoriesInput connect: ConfigurationWhereUniqueInput } -input ConfigurationUpdateWithoutTagCategoriesDataInput { +input ConfigurationUpdateWithoutSubjectCategoriesDataInput { name: String title: String auth0Domain: String @@ -587,9 +587,9 @@ input ConfigurationUpdateWithoutTagCategoriesDataInput { bugReporting: BugReporting } -input ConfigurationUpsertWithoutTagCategoriesInput { - update: ConfigurationUpdateWithoutTagCategoriesDataInput! - create: ConfigurationCreateWithoutTagCategoriesInput! +input ConfigurationUpsertWithoutSubjectCategoriesInput { + update: ConfigurationUpdateWithoutSubjectCategoriesDataInput! + create: ConfigurationCreateWithoutSubjectCategoriesInput! } input ConfigurationWhereInput { @@ -747,9 +747,9 @@ input ConfigurationWhereInput { slackCommandKey_not_starts_with: String slackCommandKey_ends_with: String slackCommandKey_not_ends_with: String - tagCategories_every: TagCategoryWhereInput - tagCategories_some: TagCategoryWhereInput - tagCategories_none: TagCategoryWhereInput + subjectCategories_every: SubjectCategoryWhereInput + subjectCategories_some: SubjectCategoryWhereInput + subjectCategories_none: SubjectCategoryWhereInput workplaceSharing: Boolean workplaceSharing_not: Boolean bugReporting: BugReporting @@ -1458,24 +1458,27 @@ type Mutation { ): Subject! deleteSubject(where: SubjectWhereUniqueInput!): Subject deleteManySubjects(where: SubjectWhereInput): BatchPayload! + createSubjectCategory(data: SubjectCategoryCreateInput!): SubjectCategory! + updateSubjectCategory( + data: SubjectCategoryUpdateInput! + where: SubjectCategoryWhereUniqueInput! + ): SubjectCategory + updateManySubjectCategories( + data: SubjectCategoryUpdateManyMutationInput! + where: SubjectCategoryWhereInput + ): BatchPayload! + upsertSubjectCategory( + where: SubjectCategoryWhereUniqueInput! + create: SubjectCategoryCreateInput! + update: SubjectCategoryUpdateInput! + ): SubjectCategory! + deleteSubjectCategory(where: SubjectCategoryWhereUniqueInput!): SubjectCategory + deleteManySubjectCategories(where: SubjectCategoryWhereInput): BatchPayload! createTag(data: TagCreateInput!): Tag! updateTag(data: TagUpdateInput!, where: TagWhereUniqueInput!): Tag upsertTag(where: TagWhereUniqueInput!, create: TagCreateInput!, update: TagUpdateInput!): Tag! deleteTag(where: TagWhereUniqueInput!): Tag deleteManyTags(where: TagWhereInput): BatchPayload! - createTagCategory(data: TagCategoryCreateInput!): TagCategory! - updateTagCategory(data: TagCategoryUpdateInput!, where: TagCategoryWhereUniqueInput!): TagCategory - updateManyTagCategories( - data: TagCategoryUpdateManyMutationInput! - where: TagCategoryWhereInput - ): BatchPayload! - upsertTagCategory( - where: TagCategoryWhereUniqueInput! - create: TagCategoryCreateInput! - update: TagCategoryUpdateInput! - ): TagCategory! - deleteTagCategory(where: TagCategoryWhereUniqueInput!): TagCategory - deleteManyTagCategories(where: TagCategoryWhereInput): BatchPayload! createUser(data: UserCreateInput!): User! updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User updateManyUsers(data: UserUpdateManyMutationInput!, where: UserWhereInput): BatchPayload! @@ -1649,44 +1652,44 @@ type Query { first: Int last: Int ): SubjectConnection! - tag(where: TagWhereUniqueInput!): Tag - tags( - where: TagWhereInput - orderBy: TagOrderByInput + subjectCategory(where: SubjectCategoryWhereUniqueInput!): SubjectCategory + subjectCategories( + where: SubjectCategoryWhereInput + orderBy: SubjectCategoryOrderByInput skip: Int after: String before: String first: Int last: Int - ): [Tag]! - tagsConnection( - where: TagWhereInput - orderBy: TagOrderByInput + ): [SubjectCategory]! + subjectCategoriesConnection( + where: SubjectCategoryWhereInput + orderBy: SubjectCategoryOrderByInput skip: Int after: String before: String first: Int last: Int - ): TagConnection! - tagCategory(where: TagCategoryWhereUniqueInput!): TagCategory - tagCategories( - where: TagCategoryWhereInput - orderBy: TagCategoryOrderByInput + ): SubjectCategoryConnection! + tag(where: TagWhereUniqueInput!): Tag + tags( + where: TagWhereInput + orderBy: TagOrderByInput skip: Int after: String before: String first: Int last: Int - ): [TagCategory]! - tagCategoriesConnection( - where: TagCategoryWhereInput - orderBy: TagCategoryOrderByInput + ): [Tag]! + tagsConnection( + where: TagWhereInput + orderBy: TagOrderByInput skip: Int after: String before: String first: Int last: Int - ): TagCategoryConnection! + ): TagConnection! user(where: UserWhereUniqueInput!): User users( where: UserWhereInput @@ -2334,71 +2337,73 @@ type Subject { last: Int ): [User!] order: Int! - category: TagCategory! + category: SubjectCategory! createdAt: DateTime! updatedAt: DateTime! } -type SubjectConnection { - pageInfo: PageInfo! - edges: [SubjectEdge]! - aggregate: AggregateSubject! -} - -input SubjectCreateInput { - id: ID +type SubjectCategory { + id: ID! name: String! - tags: TagCreateManyWithoutLabelInput - specialists: UserCreateManyWithoutSpecialtiesInput + labels( + where: SubjectWhereInput + orderBy: SubjectOrderByInput + skip: Int + after: String + before: String + first: Int + last: Int + ): [Subject!] order: Int! - category: TagCategoryCreateOneWithoutLabelsInput! + configuration: Configuration! + createdAt: DateTime! + updatedAt: DateTime! } -input SubjectCreateManyWithoutCategoryInput { - create: [SubjectCreateWithoutCategoryInput!] - connect: [SubjectWhereUniqueInput!] +type SubjectCategoryConnection { + pageInfo: PageInfo! + edges: [SubjectCategoryEdge]! + aggregate: AggregateSubjectCategory! } -input SubjectCreateManyWithoutSpecialistsInput { - create: [SubjectCreateWithoutSpecialistsInput!] - connect: [SubjectWhereUniqueInput!] +input SubjectCategoryCreateInput { + id: ID + name: String! + labels: SubjectCreateManyWithoutCategoryInput + order: Int! + configuration: ConfigurationCreateOneWithoutSubjectCategoriesInput! } -input SubjectCreateOneWithoutTagsInput { - create: SubjectCreateWithoutTagsInput - connect: SubjectWhereUniqueInput +input SubjectCategoryCreateManyWithoutConfigurationInput { + create: [SubjectCategoryCreateWithoutConfigurationInput!] + connect: [SubjectCategoryWhereUniqueInput!] } -input SubjectCreateWithoutCategoryInput { - id: ID - name: String! - tags: TagCreateManyWithoutLabelInput - specialists: UserCreateManyWithoutSpecialtiesInput - order: Int! +input SubjectCategoryCreateOneWithoutLabelsInput { + create: SubjectCategoryCreateWithoutLabelsInput + connect: SubjectCategoryWhereUniqueInput } -input SubjectCreateWithoutSpecialistsInput { +input SubjectCategoryCreateWithoutConfigurationInput { id: ID name: String! - tags: TagCreateManyWithoutLabelInput + labels: SubjectCreateManyWithoutCategoryInput order: Int! - category: TagCategoryCreateOneWithoutLabelsInput! } -input SubjectCreateWithoutTagsInput { +input SubjectCategoryCreateWithoutLabelsInput { id: ID name: String! - specialists: UserCreateManyWithoutSpecialtiesInput order: Int! - category: TagCategoryCreateOneWithoutLabelsInput! + configuration: ConfigurationCreateOneWithoutSubjectCategoriesInput! } -type SubjectEdge { - node: Subject! +type SubjectCategoryEdge { + node: SubjectCategory! cursor: String! } -enum SubjectOrderByInput { +enum SubjectCategoryOrderByInput { id_ASC id_DESC name_ASC @@ -2411,7 +2416,7 @@ enum SubjectOrderByInput { updatedAt_DESC } -type SubjectPreviousValues { +type SubjectCategoryPreviousValues { id: ID! name: String! order: Int! @@ -2419,7 +2424,7 @@ type SubjectPreviousValues { updatedAt: DateTime! } -input SubjectScalarWhereInput { +input SubjectCategoryScalarWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2472,134 +2477,99 @@ input SubjectScalarWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [SubjectScalarWhereInput!] - OR: [SubjectScalarWhereInput!] - NOT: [SubjectScalarWhereInput!] + AND: [SubjectCategoryScalarWhereInput!] + OR: [SubjectCategoryScalarWhereInput!] + NOT: [SubjectCategoryScalarWhereInput!] } -type SubjectSubscriptionPayload { +type SubjectCategorySubscriptionPayload { mutation: MutationType! - node: Subject + node: SubjectCategory updatedFields: [String!] - previousValues: SubjectPreviousValues + previousValues: SubjectCategoryPreviousValues } -input SubjectSubscriptionWhereInput { +input SubjectCategorySubscriptionWhereInput { mutation_in: [MutationType!] updatedFields_contains: String updatedFields_contains_every: [String!] updatedFields_contains_some: [String!] - node: SubjectWhereInput - AND: [SubjectSubscriptionWhereInput!] - OR: [SubjectSubscriptionWhereInput!] - NOT: [SubjectSubscriptionWhereInput!] + node: SubjectCategoryWhereInput + AND: [SubjectCategorySubscriptionWhereInput!] + OR: [SubjectCategorySubscriptionWhereInput!] + NOT: [SubjectCategorySubscriptionWhereInput!] } -input SubjectUpdateInput { +input SubjectCategoryUpdateInput { name: String - tags: TagUpdateManyWithoutLabelInput - specialists: UserUpdateManyWithoutSpecialtiesInput + labels: SubjectUpdateManyWithoutCategoryInput order: Int - category: TagCategoryUpdateOneRequiredWithoutLabelsInput + configuration: ConfigurationUpdateOneRequiredWithoutSubjectCategoriesInput } -input SubjectUpdateManyDataInput { +input SubjectCategoryUpdateManyDataInput { name: String order: Int } -input SubjectUpdateManyMutationInput { +input SubjectCategoryUpdateManyMutationInput { name: String order: Int } -input SubjectUpdateManyWithoutCategoryInput { - create: [SubjectCreateWithoutCategoryInput!] - delete: [SubjectWhereUniqueInput!] - connect: [SubjectWhereUniqueInput!] - set: [SubjectWhereUniqueInput!] - disconnect: [SubjectWhereUniqueInput!] - update: [SubjectUpdateWithWhereUniqueWithoutCategoryInput!] - upsert: [SubjectUpsertWithWhereUniqueWithoutCategoryInput!] - deleteMany: [SubjectScalarWhereInput!] - updateMany: [SubjectUpdateManyWithWhereNestedInput!] +input SubjectCategoryUpdateManyWithoutConfigurationInput { + create: [SubjectCategoryCreateWithoutConfigurationInput!] + delete: [SubjectCategoryWhereUniqueInput!] + connect: [SubjectCategoryWhereUniqueInput!] + set: [SubjectCategoryWhereUniqueInput!] + disconnect: [SubjectCategoryWhereUniqueInput!] + update: [SubjectCategoryUpdateWithWhereUniqueWithoutConfigurationInput!] + upsert: [SubjectCategoryUpsertWithWhereUniqueWithoutConfigurationInput!] + deleteMany: [SubjectCategoryScalarWhereInput!] + updateMany: [SubjectCategoryUpdateManyWithWhereNestedInput!] } -input SubjectUpdateManyWithoutSpecialistsInput { - create: [SubjectCreateWithoutSpecialistsInput!] - delete: [SubjectWhereUniqueInput!] - connect: [SubjectWhereUniqueInput!] - set: [SubjectWhereUniqueInput!] - disconnect: [SubjectWhereUniqueInput!] - update: [SubjectUpdateWithWhereUniqueWithoutSpecialistsInput!] - upsert: [SubjectUpsertWithWhereUniqueWithoutSpecialistsInput!] - deleteMany: [SubjectScalarWhereInput!] - updateMany: [SubjectUpdateManyWithWhereNestedInput!] +input SubjectCategoryUpdateManyWithWhereNestedInput { + where: SubjectCategoryScalarWhereInput! + data: SubjectCategoryUpdateManyDataInput! } -input SubjectUpdateManyWithWhereNestedInput { - where: SubjectScalarWhereInput! - data: SubjectUpdateManyDataInput! -} - -input SubjectUpdateOneWithoutTagsInput { - create: SubjectCreateWithoutTagsInput - update: SubjectUpdateWithoutTagsDataInput - upsert: SubjectUpsertWithoutTagsInput - delete: Boolean - disconnect: Boolean - connect: SubjectWhereUniqueInput -} - -input SubjectUpdateWithoutCategoryDataInput { - name: String - tags: TagUpdateManyWithoutLabelInput - specialists: UserUpdateManyWithoutSpecialtiesInput - order: Int +input SubjectCategoryUpdateOneRequiredWithoutLabelsInput { + create: SubjectCategoryCreateWithoutLabelsInput + update: SubjectCategoryUpdateWithoutLabelsDataInput + upsert: SubjectCategoryUpsertWithoutLabelsInput + connect: SubjectCategoryWhereUniqueInput } -input SubjectUpdateWithoutSpecialistsDataInput { +input SubjectCategoryUpdateWithoutConfigurationDataInput { name: String - tags: TagUpdateManyWithoutLabelInput + labels: SubjectUpdateManyWithoutCategoryInput order: Int - category: TagCategoryUpdateOneRequiredWithoutLabelsInput } -input SubjectUpdateWithoutTagsDataInput { +input SubjectCategoryUpdateWithoutLabelsDataInput { name: String - specialists: UserUpdateManyWithoutSpecialtiesInput order: Int - category: TagCategoryUpdateOneRequiredWithoutLabelsInput + configuration: ConfigurationUpdateOneRequiredWithoutSubjectCategoriesInput } -input SubjectUpdateWithWhereUniqueWithoutCategoryInput { - where: SubjectWhereUniqueInput! - data: SubjectUpdateWithoutCategoryDataInput! +input SubjectCategoryUpdateWithWhereUniqueWithoutConfigurationInput { + where: SubjectCategoryWhereUniqueInput! + data: SubjectCategoryUpdateWithoutConfigurationDataInput! } -input SubjectUpdateWithWhereUniqueWithoutSpecialistsInput { - where: SubjectWhereUniqueInput! - data: SubjectUpdateWithoutSpecialistsDataInput! +input SubjectCategoryUpsertWithoutLabelsInput { + update: SubjectCategoryUpdateWithoutLabelsDataInput! + create: SubjectCategoryCreateWithoutLabelsInput! } -input SubjectUpsertWithoutTagsInput { - update: SubjectUpdateWithoutTagsDataInput! - create: SubjectCreateWithoutTagsInput! +input SubjectCategoryUpsertWithWhereUniqueWithoutConfigurationInput { + where: SubjectCategoryWhereUniqueInput! + update: SubjectCategoryUpdateWithoutConfigurationDataInput! + create: SubjectCategoryCreateWithoutConfigurationInput! } -input SubjectUpsertWithWhereUniqueWithoutCategoryInput { - where: SubjectWhereUniqueInput! - update: SubjectUpdateWithoutCategoryDataInput! - create: SubjectCreateWithoutCategoryInput! -} - -input SubjectUpsertWithWhereUniqueWithoutSpecialistsInput { - where: SubjectWhereUniqueInput! - update: SubjectUpdateWithoutSpecialistsDataInput! - create: SubjectCreateWithoutSpecialistsInput! -} - -input SubjectWhereInput { +input SubjectCategoryWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2628,12 +2598,9 @@ input SubjectWhereInput { name_not_starts_with: String name_ends_with: String name_not_ends_with: String - tags_every: TagWhereInput - tags_some: TagWhereInput - tags_none: TagWhereInput - specialists_every: UserWhereInput - specialists_some: UserWhereInput - specialists_none: UserWhereInput + labels_every: SubjectWhereInput + labels_some: SubjectWhereInput + labels_none: SubjectWhereInput order: Int order_not: Int order_in: [Int!] @@ -2642,7 +2609,7 @@ input SubjectWhereInput { order_lte: Int order_gt: Int order_gte: Int - category: TagCategoryWhereInput + configuration: ConfigurationWhereInput createdAt: DateTime createdAt_not: DateTime createdAt_in: [DateTime!] @@ -2659,100 +2626,75 @@ input SubjectWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [SubjectWhereInput!] - OR: [SubjectWhereInput!] - NOT: [SubjectWhereInput!] + AND: [SubjectCategoryWhereInput!] + OR: [SubjectCategoryWhereInput!] + NOT: [SubjectCategoryWhereInput!] } -input SubjectWhereUniqueInput { +input SubjectCategoryWhereUniqueInput { id: ID } -type Subscription { - answer(where: AnswerSubscriptionWhereInput): AnswerSubscriptionPayload - configuration(where: ConfigurationSubscriptionWhereInput): ConfigurationSubscriptionPayload - flag(where: FlagSubscriptionWhereInput): FlagSubscriptionPayload - historyAction(where: HistoryActionSubscriptionWhereInput): HistoryActionSubscriptionPayload - question(where: QuestionSubscriptionWhereInput): QuestionSubscriptionPayload - source(where: SourceSubscriptionWhereInput): SourceSubscriptionPayload - subject(where: SubjectSubscriptionWhereInput): SubjectSubscriptionPayload - tag(where: TagSubscriptionWhereInput): TagSubscriptionPayload - tagCategory(where: TagCategorySubscriptionWhereInput): TagCategorySubscriptionPayload - user(where: UserSubscriptionWhereInput): UserSubscriptionPayload - zNode(where: ZNodeSubscriptionWhereInput): ZNodeSubscriptionPayload -} - -type Tag { - id: ID! - label: Subject - node: ZNode! - user: User! - createdAt: DateTime! - updatedAt: DateTime! +type SubjectConnection { + pageInfo: PageInfo! + edges: [SubjectEdge]! + aggregate: AggregateSubject! } -type TagCategory { - id: ID! +input SubjectCreateInput { + id: ID name: String! - labels( - where: SubjectWhereInput - orderBy: SubjectOrderByInput - skip: Int - after: String - before: String - first: Int - last: Int - ): [Subject!] + tags: TagCreateManyWithoutLabelInput + specialists: UserCreateManyWithoutSpecialtiesInput order: Int! - configuration: Configuration! - createdAt: DateTime! - updatedAt: DateTime! + category: SubjectCategoryCreateOneWithoutLabelsInput! } -type TagCategoryConnection { - pageInfo: PageInfo! - edges: [TagCategoryEdge]! - aggregate: AggregateTagCategory! +input SubjectCreateManyWithoutCategoryInput { + create: [SubjectCreateWithoutCategoryInput!] + connect: [SubjectWhereUniqueInput!] } -input TagCategoryCreateInput { - id: ID - name: String! - labels: SubjectCreateManyWithoutCategoryInput - order: Int! - configuration: ConfigurationCreateOneWithoutTagCategoriesInput! +input SubjectCreateManyWithoutSpecialistsInput { + create: [SubjectCreateWithoutSpecialistsInput!] + connect: [SubjectWhereUniqueInput!] } -input TagCategoryCreateManyWithoutConfigurationInput { - create: [TagCategoryCreateWithoutConfigurationInput!] - connect: [TagCategoryWhereUniqueInput!] +input SubjectCreateOneWithoutTagsInput { + create: SubjectCreateWithoutTagsInput + connect: SubjectWhereUniqueInput } -input TagCategoryCreateOneWithoutLabelsInput { - create: TagCategoryCreateWithoutLabelsInput - connect: TagCategoryWhereUniqueInput +input SubjectCreateWithoutCategoryInput { + id: ID + name: String! + tags: TagCreateManyWithoutLabelInput + specialists: UserCreateManyWithoutSpecialtiesInput + order: Int! } -input TagCategoryCreateWithoutConfigurationInput { +input SubjectCreateWithoutSpecialistsInput { id: ID name: String! - labels: SubjectCreateManyWithoutCategoryInput + tags: TagCreateManyWithoutLabelInput order: Int! + category: SubjectCategoryCreateOneWithoutLabelsInput! } -input TagCategoryCreateWithoutLabelsInput { +input SubjectCreateWithoutTagsInput { id: ID name: String! + specialists: UserCreateManyWithoutSpecialtiesInput order: Int! - configuration: ConfigurationCreateOneWithoutTagCategoriesInput! + category: SubjectCategoryCreateOneWithoutLabelsInput! } -type TagCategoryEdge { - node: TagCategory! +type SubjectEdge { + node: Subject! cursor: String! } -enum TagCategoryOrderByInput { +enum SubjectOrderByInput { id_ASC id_DESC name_ASC @@ -2765,7 +2707,7 @@ enum TagCategoryOrderByInput { updatedAt_DESC } -type TagCategoryPreviousValues { +type SubjectPreviousValues { id: ID! name: String! order: Int! @@ -2773,7 +2715,7 @@ type TagCategoryPreviousValues { updatedAt: DateTime! } -input TagCategoryScalarWhereInput { +input SubjectScalarWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2826,99 +2768,134 @@ input TagCategoryScalarWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [TagCategoryScalarWhereInput!] - OR: [TagCategoryScalarWhereInput!] - NOT: [TagCategoryScalarWhereInput!] + AND: [SubjectScalarWhereInput!] + OR: [SubjectScalarWhereInput!] + NOT: [SubjectScalarWhereInput!] } -type TagCategorySubscriptionPayload { +type SubjectSubscriptionPayload { mutation: MutationType! - node: TagCategory + node: Subject updatedFields: [String!] - previousValues: TagCategoryPreviousValues + previousValues: SubjectPreviousValues } -input TagCategorySubscriptionWhereInput { +input SubjectSubscriptionWhereInput { mutation_in: [MutationType!] updatedFields_contains: String updatedFields_contains_every: [String!] updatedFields_contains_some: [String!] - node: TagCategoryWhereInput - AND: [TagCategorySubscriptionWhereInput!] - OR: [TagCategorySubscriptionWhereInput!] - NOT: [TagCategorySubscriptionWhereInput!] + node: SubjectWhereInput + AND: [SubjectSubscriptionWhereInput!] + OR: [SubjectSubscriptionWhereInput!] + NOT: [SubjectSubscriptionWhereInput!] } -input TagCategoryUpdateInput { +input SubjectUpdateInput { name: String - labels: SubjectUpdateManyWithoutCategoryInput + tags: TagUpdateManyWithoutLabelInput + specialists: UserUpdateManyWithoutSpecialtiesInput order: Int - configuration: ConfigurationUpdateOneRequiredWithoutTagCategoriesInput + category: SubjectCategoryUpdateOneRequiredWithoutLabelsInput } -input TagCategoryUpdateManyDataInput { +input SubjectUpdateManyDataInput { name: String order: Int } -input TagCategoryUpdateManyMutationInput { +input SubjectUpdateManyMutationInput { name: String order: Int } -input TagCategoryUpdateManyWithoutConfigurationInput { - create: [TagCategoryCreateWithoutConfigurationInput!] - delete: [TagCategoryWhereUniqueInput!] - connect: [TagCategoryWhereUniqueInput!] - set: [TagCategoryWhereUniqueInput!] - disconnect: [TagCategoryWhereUniqueInput!] - update: [TagCategoryUpdateWithWhereUniqueWithoutConfigurationInput!] - upsert: [TagCategoryUpsertWithWhereUniqueWithoutConfigurationInput!] - deleteMany: [TagCategoryScalarWhereInput!] - updateMany: [TagCategoryUpdateManyWithWhereNestedInput!] +input SubjectUpdateManyWithoutCategoryInput { + create: [SubjectCreateWithoutCategoryInput!] + delete: [SubjectWhereUniqueInput!] + connect: [SubjectWhereUniqueInput!] + set: [SubjectWhereUniqueInput!] + disconnect: [SubjectWhereUniqueInput!] + update: [SubjectUpdateWithWhereUniqueWithoutCategoryInput!] + upsert: [SubjectUpsertWithWhereUniqueWithoutCategoryInput!] + deleteMany: [SubjectScalarWhereInput!] + updateMany: [SubjectUpdateManyWithWhereNestedInput!] } -input TagCategoryUpdateManyWithWhereNestedInput { - where: TagCategoryScalarWhereInput! - data: TagCategoryUpdateManyDataInput! +input SubjectUpdateManyWithoutSpecialistsInput { + create: [SubjectCreateWithoutSpecialistsInput!] + delete: [SubjectWhereUniqueInput!] + connect: [SubjectWhereUniqueInput!] + set: [SubjectWhereUniqueInput!] + disconnect: [SubjectWhereUniqueInput!] + update: [SubjectUpdateWithWhereUniqueWithoutSpecialistsInput!] + upsert: [SubjectUpsertWithWhereUniqueWithoutSpecialistsInput!] + deleteMany: [SubjectScalarWhereInput!] + updateMany: [SubjectUpdateManyWithWhereNestedInput!] } -input TagCategoryUpdateOneRequiredWithoutLabelsInput { - create: TagCategoryCreateWithoutLabelsInput - update: TagCategoryUpdateWithoutLabelsDataInput - upsert: TagCategoryUpsertWithoutLabelsInput - connect: TagCategoryWhereUniqueInput +input SubjectUpdateManyWithWhereNestedInput { + where: SubjectScalarWhereInput! + data: SubjectUpdateManyDataInput! } -input TagCategoryUpdateWithoutConfigurationDataInput { +input SubjectUpdateOneWithoutTagsInput { + create: SubjectCreateWithoutTagsInput + update: SubjectUpdateWithoutTagsDataInput + upsert: SubjectUpsertWithoutTagsInput + delete: Boolean + disconnect: Boolean + connect: SubjectWhereUniqueInput +} + +input SubjectUpdateWithoutCategoryDataInput { name: String - labels: SubjectUpdateManyWithoutCategoryInput + tags: TagUpdateManyWithoutLabelInput + specialists: UserUpdateManyWithoutSpecialtiesInput order: Int } -input TagCategoryUpdateWithoutLabelsDataInput { +input SubjectUpdateWithoutSpecialistsDataInput { name: String + tags: TagUpdateManyWithoutLabelInput order: Int - configuration: ConfigurationUpdateOneRequiredWithoutTagCategoriesInput + category: SubjectCategoryUpdateOneRequiredWithoutLabelsInput +} + +input SubjectUpdateWithoutTagsDataInput { + name: String + specialists: UserUpdateManyWithoutSpecialtiesInput + order: Int + category: SubjectCategoryUpdateOneRequiredWithoutLabelsInput +} + +input SubjectUpdateWithWhereUniqueWithoutCategoryInput { + where: SubjectWhereUniqueInput! + data: SubjectUpdateWithoutCategoryDataInput! } -input TagCategoryUpdateWithWhereUniqueWithoutConfigurationInput { - where: TagCategoryWhereUniqueInput! - data: TagCategoryUpdateWithoutConfigurationDataInput! +input SubjectUpdateWithWhereUniqueWithoutSpecialistsInput { + where: SubjectWhereUniqueInput! + data: SubjectUpdateWithoutSpecialistsDataInput! +} + +input SubjectUpsertWithoutTagsInput { + update: SubjectUpdateWithoutTagsDataInput! + create: SubjectCreateWithoutTagsInput! } -input TagCategoryUpsertWithoutLabelsInput { - update: TagCategoryUpdateWithoutLabelsDataInput! - create: TagCategoryCreateWithoutLabelsInput! +input SubjectUpsertWithWhereUniqueWithoutCategoryInput { + where: SubjectWhereUniqueInput! + update: SubjectUpdateWithoutCategoryDataInput! + create: SubjectCreateWithoutCategoryInput! } -input TagCategoryUpsertWithWhereUniqueWithoutConfigurationInput { - where: TagCategoryWhereUniqueInput! - update: TagCategoryUpdateWithoutConfigurationDataInput! - create: TagCategoryCreateWithoutConfigurationInput! +input SubjectUpsertWithWhereUniqueWithoutSpecialistsInput { + where: SubjectWhereUniqueInput! + update: SubjectUpdateWithoutSpecialistsDataInput! + create: SubjectCreateWithoutSpecialistsInput! } -input TagCategoryWhereInput { +input SubjectWhereInput { id: ID id_not: ID id_in: [ID!] @@ -2947,9 +2924,12 @@ input TagCategoryWhereInput { name_not_starts_with: String name_ends_with: String name_not_ends_with: String - labels_every: SubjectWhereInput - labels_some: SubjectWhereInput - labels_none: SubjectWhereInput + tags_every: TagWhereInput + tags_some: TagWhereInput + tags_none: TagWhereInput + specialists_every: UserWhereInput + specialists_some: UserWhereInput + specialists_none: UserWhereInput order: Int order_not: Int order_in: [Int!] @@ -2958,7 +2938,7 @@ input TagCategoryWhereInput { order_lte: Int order_gt: Int order_gte: Int - configuration: ConfigurationWhereInput + category: SubjectCategoryWhereInput createdAt: DateTime createdAt_not: DateTime createdAt_in: [DateTime!] @@ -2975,15 +2955,38 @@ input TagCategoryWhereInput { updatedAt_lte: DateTime updatedAt_gt: DateTime updatedAt_gte: DateTime - AND: [TagCategoryWhereInput!] - OR: [TagCategoryWhereInput!] - NOT: [TagCategoryWhereInput!] + AND: [SubjectWhereInput!] + OR: [SubjectWhereInput!] + NOT: [SubjectWhereInput!] } -input TagCategoryWhereUniqueInput { +input SubjectWhereUniqueInput { id: ID } +type Subscription { + answer(where: AnswerSubscriptionWhereInput): AnswerSubscriptionPayload + configuration(where: ConfigurationSubscriptionWhereInput): ConfigurationSubscriptionPayload + flag(where: FlagSubscriptionWhereInput): FlagSubscriptionPayload + historyAction(where: HistoryActionSubscriptionWhereInput): HistoryActionSubscriptionPayload + question(where: QuestionSubscriptionWhereInput): QuestionSubscriptionPayload + source(where: SourceSubscriptionWhereInput): SourceSubscriptionPayload + subject(where: SubjectSubscriptionWhereInput): SubjectSubscriptionPayload + subjectCategory(where: SubjectCategorySubscriptionWhereInput): SubjectCategorySubscriptionPayload + tag(where: TagSubscriptionWhereInput): TagSubscriptionPayload + user(where: UserSubscriptionWhereInput): UserSubscriptionPayload + zNode(where: ZNodeSubscriptionWhereInput): ZNodeSubscriptionPayload +} + +type Tag { + id: ID! + label: Subject + node: ZNode! + user: User! + createdAt: DateTime! + updatedAt: DateTime! +} + type TagConnection { pageInfo: PageInfo! edges: [TagEdge]! diff --git a/server/src/helpers/diffTags.js b/server/src/helpers/diffTags.js index 5b6dd08f4..6ab61ac6a 100644 --- a/server/src/helpers/diffTags.js +++ b/server/src/helpers/diffTags.js @@ -16,7 +16,7 @@ const diffTags = (ctx, oldCats, newCats, confId) => { promises.push( Promise.all( catsToCreate.map(cat => - ctx.prisma.mutation.createTagCategory({ + ctx.prisma.mutation.createSubjectCategory({ data: { name: cat.name, order: cat.order, @@ -43,7 +43,7 @@ const diffTags = (ctx, oldCats, newCats, confId) => { promises.push( Promise.all( catsToUpdate.map(cat => - ctx.prisma.mutation.updateTagCategory({ + ctx.prisma.mutation.updateSubjectCategory({ where: { id: cat.id }, @@ -65,7 +65,7 @@ const diffTags = (ctx, oldCats, newCats, confId) => { promises.push( Promise.all( catsToDelete.map(cat => - ctx.prisma.mutation.deleteTagCategory({ + ctx.prisma.mutation.deleteSubjectCategory({ where: { id: cat.id } }) ) diff --git a/server/src/middlewares/auth.js b/server/src/middlewares/auth.js index 42c50e610..86026f580 100644 --- a/server/src/middlewares/auth.js +++ b/server/src/middlewares/auth.js @@ -34,7 +34,7 @@ const checkJwt = async (req, res, next, prisma) => { }` ) - const specialtyId = conf.tagCategories[0].labels[1].id + const specialtyId = conf.subjectCategories[0].labels[1].id const userNoAuthUpsert = () => prisma.mutation.upsertUser( { diff --git a/server/src/middlewares/configuration.js b/server/src/middlewares/configuration.js index a49637577..0f4be1ee4 100644 --- a/server/src/middlewares/configuration.js +++ b/server/src/middlewares/configuration.js @@ -32,7 +32,7 @@ const refreshConfiguration = async tenant => { mailgunDomain mailgunApiKey slackChannelHook - tagCategories { + subjectCategories { order name labels { diff --git a/server/src/resolvers/configuration.js b/server/src/resolvers/configuration.js index 43f98edc2..64c397c0b 100644 --- a/server/src/resolvers/configuration.js +++ b/server/src/resolvers/configuration.js @@ -8,8 +8,13 @@ module.exports = { ctx.prisma.query.configuration({ where: { name: 'default' } }, info) }, Mutation: { - updateConfiguration: async (_, { authorizedDomains, tagCategories, ...args }, ctx, info) => { - const oldTagCategories = await ctx.prisma.query.tagCategories( + updateConfiguration: async ( + _, + { authorizedDomains, subjectCategories, ...args }, + ctx, + info + ) => { + const oldSubjectCategories = await ctx.prisma.query.subjectCategories( null, ` { @@ -27,8 +32,8 @@ module.exports = { await diffTags( ctx, - oldTagCategories, - JSON.parse(tagCategories), + oldSubjectCategories, + JSON.parse(subjectCategories), ctx.prisma._meta.configuration.id ) diff --git a/server/src/resolvers/question.js b/server/src/resolvers/question.js index 701ef214a..7849b0a45 100644 --- a/server/src/resolvers/question.js +++ b/server/src/resolvers/question.js @@ -2,8 +2,8 @@ const { history, ctxUser, slugify, deleteCertifedFlagIfNoLongerApplicable } = re const { algolia, slack } = require('../integrations') // TMP_TAGS -const confSubjects = ctx => - ctx.prisma._meta.configuration.tagCategories.reduce((acc, cat) => acc.concat(cat.labels), []) +const confTagLabels = ctx => + ctx.prisma._meta.configuration.subjectCategories.reduce((acc, cat) => acc.concat(cat.labels), []) module.exports = { Query: { diff --git a/server/src/schema.graphql b/server/src/schema.graphql index 959794de4..8b75694fa 100644 --- a/server/src/schema.graphql +++ b/server/src/schema.graphql @@ -1,4 +1,4 @@ -# import ZNode, Question, Answer, Source, Flag, Subject, TagCategory, HistoryAction, BugReporting from './generated/prisma.graphql' +# import ZNode, Question, Answer, Source, Flag, TagLabel, SubjectCategory, HistoryAction, BugReporting from './generated/prisma.graphql' # import ZNodeOrderByInput, ZNodeConnection, ZNodeWhereUniqueInput from './generated/prisma.graphql' # import HistoryActionWhereInput from './generated/prisma.graphql' @@ -55,7 +55,7 @@ type Mutation { updateConfiguration( title: String! - tagCategories: Json! + subjectCategories: Json! algoliaSynonyms: Json! workplaceSharing: Boolean! authorizedDomains: [String!]! @@ -110,7 +110,7 @@ type Configuration { slackCommandKey: String @admin tags: Json - tagCategories: [TagCategory!]! + subjectCategories: [SubjectCategory!]! # TMP_TAGS workplaceSharing: Boolean