From a81079bf6064920f9fdf54c8cf3f7539eae284e3 Mon Sep 17 00:00:00 2001 From: axolotle Date: Tue, 9 Mar 2021 16:04:50 +0100 Subject: [PATCH] add base query for text cards --- src/api/fragments/TextCardFields.gql | 37 ++++++++++++++++++++++++++++ src/api/queries/TextCard.gql | 31 +++++++++++++++++++++-- src/api/queries/index.js | 2 +- src/store/modules/texts.js | 6 ++--- 4 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 src/api/fragments/TextCardFields.gql diff --git a/src/api/fragments/TextCardFields.gql b/src/api/fragments/TextCardFields.gql new file mode 100644 index 0000000..b4ce845 --- /dev/null +++ b/src/api/fragments/TextCardFields.gql @@ -0,0 +1,37 @@ +fragment TextCardFields on TextInterface { + id + bundle + title + content: texte + images { + id + url + alt + } + videos { + url + } + files: fichiers { + fid + filename + filemime + url + } + families: familles { + id + uuid + name + } + # field_titre + authors: auteurs { + id + uuid + name + } + edition { + id + uuid + name + } + type: __typename +} diff --git a/src/api/queries/TextCard.gql b/src/api/queries/TextCard.gql index 7216fec..617a935 100644 --- a/src/api/queries/TextCard.gql +++ b/src/api/queries/TextCard.gql @@ -1,5 +1,32 @@ +#import "../fragments/TextCardFields.gql" + query TextRef ($id: Int!) { - textref (id: $id) { - title + text: texte (id: $id) { + ...TextCardFields + + ... on Textref { + prods: text_produits { + id + } + bounces: text_en_rebond { + id + title + authors: auteurs { + name + } + edition { + name + } + } + tags { + id + name + } + # degres_detrangement: Int + notes { + note + numero + } + } } } diff --git a/src/api/queries/index.js b/src/api/queries/index.js index fa65e28..fd2a2a6 100644 --- a/src/api/queries/index.js +++ b/src/api/queries/index.js @@ -1,3 +1,3 @@ export { default as TextsDepart } from './TextsDepart.gql' -export { default as TextRef } from './TextRef.gql' +export { default as TextCard } from './TextCard.gql' export { default as TextdepartRecursive } from './TextdepartRecursive.gql' diff --git a/src/store/modules/texts.js b/src/store/modules/texts.js index 7911d73..89aa7f2 100644 --- a/src/store/modules/texts.js +++ b/src/store/modules/texts.js @@ -1,7 +1,7 @@ import api from '@/api' import { print } from 'graphql/language/printer' import { - TextsDepart, TextRef, TextdepartRecursive + TextsDepart, TextCard, TextdepartRecursive } from '@/api/queries' import TextdepartRecursiveWithDepth from '@/api/queries/TextdepartRecursiveWithDepth.gql' @@ -25,8 +25,8 @@ export default { }, 'GET_TEXT' (store, { id }) { - return api.post('', { query: print(TextRef), variables: { id } }) - .then(data => (data.data.data)) + return api.post('', { query: print(TextCard), variables: { id } }) + .then(data => (data.data.data.text)) }, 'GET_TREE' (store, id) {