-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from datopian/feature/apollo-setup
Feature/apollo setup
- Loading branch information
Showing
25 changed files
with
914 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default function ErrorMessage({ message }) { | ||
return ( | ||
<aside> | ||
{message} | ||
<style jsx>{` | ||
aside { | ||
padding: 1.5em; | ||
font-size: 14px; | ||
color: white; | ||
background-color: red; | ||
} | ||
`}</style> | ||
</aside> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,45 @@ | ||
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'; | ||
|
||
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 | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
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 <ErrorMessage message="Error loading dataset." />; | ||
if (loading) return <div>Loading</div>; | ||
|
||
const { result } = data.dataset; | ||
const resource = result.resources.find( | ||
(item) => item.name === variables.resource | ||
); | ||
|
||
export default function DataExplorer({ resource }) { | ||
return <>{JSON.stringify(resource)}</>; | ||
} |
Oops, something went wrong.