From 2bf998d1baa8dba4621c41152cc73428b8e50625 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 20 Dec 2019 20:20:47 +0100 Subject: [PATCH] DRY graphql query with fragments This is also adding `disabled`, `deleted` flags. I don't know if it would change anything in the template, but now they are there. --- webapp/graphql/Search.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/webapp/graphql/Search.js b/webapp/graphql/Search.js index 4d5f47f38..9b142b429 100644 --- a/webapp/graphql/Search.js +++ b/webapp/graphql/Search.js @@ -1,26 +1,23 @@ import gql from 'graphql-tag' +import { userFragment, postFragment } from './Fragments' export const findResourcesQuery = gql` + ${userFragment} + ${postFragment} + query($query: String!) { findResources(query: $query, limit: 5) { __typename ... on Post { - id - title - slug + ...post commentsCount shoutedCount - createdAt author { - id - name + ...user } } ... on User { - id - name - slug - avatar + ...user } } }