<commit_before># https://github.com/este/este/wiki/GraphQL
# https://www.prisma.io/features/data-modeling/

# Note Prisma does not support interfaces nor union types yet.
# https://github.com/prismagraphql/prisma/issues/165

type User {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  # TODO: Refactor to auth providers. Email, Facebook, Twitter, etc.
  email: String! @unique
  password: String!
  # TODO: Refactor to Theme.
  themeName: String
  # Created by a user.
  webs: [Web!]!
  pages: [Page!]!
  elements: [Element!]!
  images: [Image!]!
}

type Web {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  name: String!
  creator: User!
  pages: [Page!]!
}

type Page {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  title: String!
  creator: User!
  web: Web!
  element: Element!
}

# Prisma does not support interfaces nor union types yet.
# https://github.com/prismagraphql/prisma/issues/165
# This is a workaround. Otherwise we could use the union:
# Example: union ElementValue = Text | Image | Children
# This enum ensures a good enough consistency.
enum ElementType {
  TEXT
  IMAGE
  CHILDREN
}

type Element {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  name: String
  type: ElementType!
  # Text, image, and children. Will be merged to value union type someday.
  text: String
  textFormat: String! @default(value: "CommonMark")
  image: Image
  children: [Child!]! @relation(name: "ElementChildren")
  creator: User!
  parent: [Child!]! @relation(name: "ChildElement")
}
<commit_msg>fix deletion bug with related models (#1555)<commit_after># https://github.com/este/este/wiki/GraphQL
# https://www.prisma.io/features/data-modeling/

# Note Prisma does not support interfaces nor union types yet.
# https://github.com/prismagraphql/prisma/issues/165

type User {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  # TODO: Refactor to auth providers. Email, Facebook, Twitter, etc.
  email: String! @unique
  password: String!
  # TODO: Refactor to Theme.
  themeName: String
  # Created by a user.
  webs: [Web!]!
  pages: [Page!]!
  elements: [Element!]!
  images: [Image!]!
}

type Web {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  name: String!
  creator: User!
  pages: [Page!]! @relation(name: "WebPage", onDelete: CASCADE)
}

type Page {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  title: String!
  creator: User!
  web: Web! @relation(name: "WebPage", onDelete: SET_NULL)
  element: Element!
}

# Prisma does not support interfaces nor union types yet.
# https://github.com/prismagraphql/prisma/issues/165
# This is a workaround. Otherwise we could use the union:
# Example: union ElementValue = Text | Image | Children
# This enum ensures a good enough consistency.
enum ElementType {
  TEXT
  IMAGE
  CHILDREN
}

type Element {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  name: String
  type: ElementType!
  # Text, image, and children. Will be merged to value union type someday.
  text: String
  textFormat: String! @default(value: "CommonMark")
  image: Image
  children: [Child!]! @relation(name: "ElementChildren")
  creator: User!
  parent: [Child!]! @relation(name: "ChildElement")
}

{'fraction_non_alphanumeric': 0.12133251833740831, 'fraction_numerical': 0.004889975550122249, 'mean_word_length': 3.996946564885496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '78539', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1082, 'n_words': 350}