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.
This commit is contained in:
roschaefer 2019-12-20 20:20:47 +01:00
parent f1b581aa86
commit 2bf998d1ba

View File

@ -1,26 +1,23 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { userFragment, postFragment } from './Fragments'
export const findResourcesQuery = gql` export const findResourcesQuery = gql`
${userFragment}
${postFragment}
query($query: String!) { query($query: String!) {
findResources(query: $query, limit: 5) { findResources(query: $query, limit: 5) {
__typename __typename
... on Post { ... on Post {
id ...post
title
slug
commentsCount commentsCount
shoutedCount shoutedCount
createdAt
author { author {
id ...user
name
} }
} }
... on User { ... on User {
id ...user
name
slug
avatar
} }
} }
} }