[refactor][m]: implement efficient gql management system (#41)
This commit is contained in:
@@ -1,21 +1,7 @@
|
||||
import Link from 'next/link';
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const GET_ORG_QUERY = gql`
|
||||
query dataset($id: String) {
|
||||
dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") {
|
||||
result {
|
||||
organization {
|
||||
name
|
||||
title
|
||||
image_url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import ErrorMessage from '../Error';
|
||||
import { GET_ORG_QUERY } from '../../graphql/queries';
|
||||
|
||||
export default function Org({ variables }) {
|
||||
const { loading, error, data } = useQuery(GET_ORG_QUERY, {
|
||||
|
||||
@@ -1,27 +1,10 @@
|
||||
import Link from 'next/link';
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const GET_DATAPACKAGE_QUERY = gql`
|
||||
query dataset($id: String) {
|
||||
dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") {
|
||||
result {
|
||||
name
|
||||
resources {
|
||||
name
|
||||
title
|
||||
format
|
||||
created
|
||||
last_modified
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import ErrorMessage from '../Error';
|
||||
import { GET_RESOURCES_QUERY } from '../../graphql/queries';
|
||||
|
||||
export default function Resources({ variables }) {
|
||||
const { loading, error, data } = useQuery(GET_DATAPACKAGE_QUERY, {
|
||||
const { loading, error, data } = useQuery(GET_RESOURCES_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
|
||||
|
||||
@@ -1,29 +1,10 @@
|
||||
import Link from 'next/link';
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const QUERY = gql`
|
||||
query search($q: String, $sort: String, $rows: Int) {
|
||||
search(q: $q, sort: $sort, rows: $rows)
|
||||
@rest(type: "Search", path: "package_search?{args}") {
|
||||
result {
|
||||
results {
|
||||
name
|
||||
title
|
||||
organization {
|
||||
name
|
||||
title
|
||||
description
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import ErrorMessage from '../Error';
|
||||
import { SEARCH_QUERY } from '../../graphql/queries';
|
||||
|
||||
function Recent() {
|
||||
const { loading, error, data } = useQuery(QUERY, {
|
||||
const { loading, error, data } = useQuery(SEARCH_QUERY, {
|
||||
variables: {
|
||||
sort: 'metadata_created desc',
|
||||
rows: 3,
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
import Link from 'next/link';
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const QUERY = gql`
|
||||
query dataset($id: String) {
|
||||
dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") {
|
||||
result {
|
||||
resources {
|
||||
name
|
||||
id
|
||||
title
|
||||
description
|
||||
format
|
||||
size
|
||||
created
|
||||
last_modified
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import ErrorMessage from '../Error';
|
||||
import { GET_RESOURCES_QUERY } from '../../graphql/queries';
|
||||
|
||||
export default function About({ variables }) {
|
||||
const { loading, error, data } = useQuery(QUERY, {
|
||||
const { loading, error, data } = useQuery(GET_RESOURCES_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
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
import Link from 'next/link';
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const QUERY = gql`
|
||||
query dataset($id: String) {
|
||||
dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") {
|
||||
result {
|
||||
resources {
|
||||
name
|
||||
id
|
||||
title
|
||||
description
|
||||
format
|
||||
size
|
||||
created
|
||||
last_modified
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import ErrorMessage from '../Error';
|
||||
import { GET_RESOURCES_QUERY } from '../../graphql/queries';
|
||||
|
||||
export default function DataExplorer({ variables }) {
|
||||
const { loading, error, data } = useQuery(QUERY, {
|
||||
const { loading, error, data } = useQuery(GET_RESOURCES_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
|
||||
|
||||
@@ -1,28 +1,10 @@
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import Item from './Item';
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const QUERY = gql`
|
||||
query search($q: String, $sort: String) {
|
||||
search(q: $q, sort: $sort)
|
||||
@rest(type: "Search", path: "package_search?{args}") {
|
||||
result {
|
||||
results {
|
||||
name
|
||||
title
|
||||
organization {
|
||||
name
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { SEARCH_QUERY } from '../../graphql/queries';
|
||||
|
||||
export default function List({ variables }) {
|
||||
const { loading, error, data } = useQuery(QUERY, {
|
||||
const { loading, error, data } = useQuery(SEARCH_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
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import ErrorMessage from '../Error';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const QUERY = gql`
|
||||
query search($q: String, $sort: String) {
|
||||
search(q: $q, sort: $sort)
|
||||
@rest(type: "Search", path: "package_search?{args}") {
|
||||
result {
|
||||
count
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import ErrorMessage from '../Error';
|
||||
import { GET_TOTAL_COUNT_QUERY } from '../../graphql/queries';
|
||||
|
||||
export default function Total({ variables }) {
|
||||
const { loading, error, data } = useQuery(QUERY, {
|
||||
const { loading, error, data } = useQuery(GET_TOTAL_COUNT_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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user