[refactor][m]: implement efficient gql management system (#41)

This commit is contained in:
Tavares Hansen
2020-08-03 18:39:17 -07:00
parent cee55cf10d
commit f8197f865c
18 changed files with 201 additions and 310 deletions

View File

@@ -1,19 +1,10 @@
import ErrorMessage from '../Error';
import parse from 'html-react-parser';
import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
const QUERY = gql`
query posts {
posts @rest(type: "Posts", path: "", endpoint: "wordpress-posts") {
found
posts
}
}
`;
import ErrorMessage from '../Error';
import { GET_POSTS_QUERY } from '../../graphql/queries';
export default function List() {
const { loading, error, data } = useQuery(QUERY, {
const { loading, error, data } = useQuery(GET_POSTS_QUERY, {
// Setting this value to true will make the component rerender when
// the "networkStatus" changes, so we are able to know if it is fetching
// more data

View File

@@ -1,22 +1,10 @@
import ErrorMessage from '../Error';
import parse from 'html-react-parser';
import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
const QUERY = gql`
query page($slug: String) {
page(slug: $slug)
@rest(type: "Page", path: "{args.slug}", endpoint: "wordpress") {
title
content
modified
featured_image
}
}
`;
import ErrorMessage from '../Error';
import { GET_PAGE_QUERY } from '../../graphql/queries';
export default function Page({ variables }) {
const { loading, error, data } = useQuery(QUERY, {
const { loading, error, data } = useQuery(GET_PAGE_QUERY, {
variables,
// Setting this value to true will make the component rerender when
// the "networkStatus" changes, so we are able to know if it is fetching

View File

@@ -1,22 +1,10 @@
import ErrorMessage from '../Error';
import parse from 'html-react-parser';
import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
const QUERY = gql`
query page($slug: String) {
page(slug: $slug)
@rest(type: "Page", path: "{args.slug}", endpoint: "wordpress") {
title
content
modified
featured_image
}
}
`;
import ErrorMessage from '../Error';
import { GET_PAGE_QUERY } from '../../graphql/queries';
export default function Post({ variables }) {
const { loading, error, data } = useQuery(QUERY, {
const { loading, error, data } = useQuery(GET_PAGE_QUERY, {
variables,
// Setting this value to true will make the component rerender when
// the "networkStatus" changes, so we are able to know if it is fetching