瀏覽代碼

add new fragments for different levels of data

axolotle 3 年之前
父節點
當前提交
d1eea1f1e6
共有 4 個文件被更改,包括 140 次插入0 次删除
  1. 47 0
      src/api/fragments/NodeFull.gql
  2. 52 0
      src/api/fragments/NodeInitial.gql
  3. 38 0
      src/api/fragments/NodePartial.gql
  4. 3 0
      src/api/fragments/index.js

+ 47 - 0
src/api/fragments/NodeFull.gql

@@ -0,0 +1,47 @@
+# This fragment queries data needed for an object to be displayed as a `Node`
+
+fragment NodeFull on TextInterface {
+  id
+
+  ... on Textref {
+    preTitle: field_titre_regular
+    title: field_titre_italique
+    link: lien_reference {
+      title
+      url
+    }
+
+    edition {
+      name
+    }
+
+    notes {
+      content: note
+      number: numero
+    }
+  }
+
+  ... on Textprod {
+    notes {
+      content: note
+      number: numero
+
+      links: liens {
+        # FIXME probably need to query titles and stuff on `Textref` or `Creation`
+        id
+        type: __typename
+        variant: familles {
+          id
+        }
+        ... on Textprod {
+          parents: text_de_depart {
+            id
+            variant: familles {
+              id
+            }
+          }
+        }
+      }
+    }
+  }
+}

+ 52 - 0
src/api/fragments/NodeInitial.gql

@@ -0,0 +1,52 @@
+# This fragment queries some elementary data to define the content structure
+
+fragment NodeInitial on TextInterface {
+  id
+  type: bundle
+  variant: familles {
+    id
+  }
+
+  ... on Textprod {
+    parents: text_de_depart {
+      id
+      variant: familles {
+        id
+      }
+    }
+
+    siblings: text_en_rebond {
+      id
+      variant: familles {
+        id
+      }
+    }
+  }
+
+  ... on Textref {
+
+    siblings: text_en_rebond {
+      id
+      variant: familles {
+        id
+      }
+    }
+
+    authors: auteurs {
+      id
+      name
+      first_name
+      last_name
+    }
+
+    preTitle: field_titre_regular
+    title: field_titre_italique
+
+    children: text_produits {
+      id
+      variant: familles {
+        id
+      }
+    }
+  }
+}

+ 38 - 0
src/api/fragments/NodePartial.gql

@@ -0,0 +1,38 @@
+# This fragment queries data needed for an object to be displayed as a `MiniNodeCard`
+
+fragment NodePartial on TextInterface {
+  id
+  content: texte
+
+  # Needed by `Creation`
+  images {
+    id
+    url
+    alt
+  }
+
+  ... on Textprod {
+    tags: tagsprod {
+      id
+      name
+    }
+  }
+
+  ... on Textref {
+    tags {
+      id
+      name
+    }
+
+    strangeness: degres_detrangement
+
+    edition {
+      name
+    }
+  }
+
+
+
+  # For debug
+  path
+}

+ 3 - 0
src/api/fragments/index.js

@@ -0,0 +1,3 @@
+export { default as NodeFull } from './NodeFull.gql'
+export { default as NodeInitial } from './NodeInitial.gql'
+export { default as NodePartial } from './NodePartial.gql'