diff --git a/components/resource/About.tsx b/components/resource/About.tsx
index e4a28423..c750e3e7 100644
--- a/components/resource/About.tsx
+++ b/components/resource/About.tsx
@@ -1,6 +1,41 @@
import Link from 'next/link';
+import ErrorMessage from '../Error';
+import { NetworkStatus } from 'apollo-client';
+import { useQuery } from '@apollo/react-hooks';
+import gql from 'graphql-tag';
-export default function About({ resource }) {
+export const QUERY = gql`
+ query dataset($id: String!) {
+ dataset(id: $id) {
+ result {
+ resources {
+ name
+ id
+ url
+ format
+ title
+ created
+ last_modified
+ }
+ }
+ }
+ }
+`;
+
+export default function About({ variables }) {
+ 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
+ // more data
+ notifyOnNetworkStatusChange: true,
+ });
+
+ if (error) return
| {resource.created} | {resource.last_modified || ''} |
-
+
{resource.format}
diff --git a/components/resource/DataExplorer.tsx b/components/resource/DataExplorer.tsx
index 6f2fbd8a..ee35308d 100644
--- a/components/resource/DataExplorer.tsx
+++ b/components/resource/DataExplorer.tsx
@@ -1,5 +1,41 @@
import Link from 'next/link';
+import ErrorMessage from '../Error';
+import { NetworkStatus } from 'apollo-client';
+import { useQuery } from '@apollo/react-hooks';
+import gql from 'graphql-tag';
+
+export const QUERY = gql`
+ query dataset($id: String!) {
+ dataset(id: $id) {
+ result {
+ resources {
+ name
+ id
+ url
+ format
+ title
+ created
+ last_modified
+ }
+ }
+ }
+ }
+`;
+
+export default function DataExplorer({ variables }) {
+ 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
+ // more data
+ notifyOnNetworkStatusChange: true,
+ });
+
+ if (error) return Loading ;
+
+ const { result } = data.dataset;
+ const resource = result.resources[0];
-export default function DataExplorer({ resource }) {
return <>{JSON.stringify(resource)}>;
}
diff --git a/pages/[org]/[dataset]/r/[resource]/index.tsx b/pages/[org]/[dataset]/r/[resource]/index.tsx
index ee9dfdd5..351841e5 100644
--- a/pages/[org]/[dataset]/r/[resource]/index.tsx
+++ b/pages/[org]/[dataset]/r/[resource]/index.tsx
@@ -1,4 +1,7 @@
import { GetServerSideProps } from 'next';
+import gql from 'graphql-tag';
+import { useQuery } from '@apollo/react-hooks';
+import { initializeApollo } from '../../../../../lib/apolloClient';
import config from '../../../../../config';
import utils from '../../../../../utils';
import Head from 'next/head';
@@ -6,39 +9,64 @@ import Nav from '../../../../../components/home/Nav';
import About from '../../../../../components/resource/About';
import DataExplorer from '../../../../../components/resource/DataExplorer';
-function Resource({ resource }) {
+const QUERY = gql`
+ query dataset($id: String!) {
+ dataset(id: $id) {
+ result {
+ resources {
+ name
+ title
+ }
+ }
+ }
+ }
+`;
+
+function Resource({ variables }) {
+ const {
+ data: {
+ dataset: { result },
+ },
+ } = useQuery(QUERY, { variables });
+
return (
<>
- - {resource.title || resource.name} + {result.resources[0].title || result.resources[0].name}- |