[ckan api + apollo][l]: setup apollo client to connect to actual CKAN API.
This commit is contained in:
@@ -4,18 +4,17 @@ import { NetworkStatus } from 'apollo-client';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const DEFAULT_SEARCH_QUERY = gql`
|
||||
query search($query: SearchQuery!) {
|
||||
search(query: $query) {
|
||||
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
|
||||
notes
|
||||
organization {
|
||||
name
|
||||
title
|
||||
description
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,16 +23,13 @@ export const DEFAULT_SEARCH_QUERY = gql`
|
||||
`;
|
||||
|
||||
export default function List({ variables }) {
|
||||
const { loading, error, data, fetchMore, networkStatus } = useQuery(
|
||||
DEFAULT_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
|
||||
// more data
|
||||
notifyOnNetworkStatusChange: true,
|
||||
}
|
||||
);
|
||||
const { loading, error, data, fetchMore, networkStatus } = useQuery(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
|
||||
// more data
|
||||
notifyOnNetworkStatusChange: true,
|
||||
});
|
||||
|
||||
if (error) return <ErrorMessage message="Error loading search results." />;
|
||||
if (loading) return <div>Loading</div>;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const GET_NUMBER_OF_DATASETS = gql`
|
||||
query search($query: SearchQuery!) {
|
||||
search(query: $query) {
|
||||
const QUERY = gql`
|
||||
query search($q: String, $sort: String) {
|
||||
search(q: $q, sort: $sort)
|
||||
@rest(type: "Search", path: "package_search?{args}") {
|
||||
result {
|
||||
count
|
||||
}
|
||||
@@ -12,7 +13,7 @@ export const GET_NUMBER_OF_DATASETS = gql`
|
||||
`;
|
||||
|
||||
export default function Total({ variables }) {
|
||||
const { loading, error, data } = useQuery(GET_NUMBER_OF_DATASETS, {
|
||||
const { loading, error, data } = useQuery(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