GitXplorerGitXplorer
d

exit-lockdown

public
4 stars
2 forks
17 issues

Commits

List of commits on branch master.
Verified
85df0738788efc8700c085f018d576facc33fbda

Merge pull request #5 from debs-obrien/dependabot/npm_and_yarn/http-proxy-1.18.1

ddebs-obrien committed 4 years ago
Verified
ea86f010f899e34775ef6e0875fc530acb21f846

Bump http-proxy from 1.18.0 to 1.18.1

ddependabot[bot] committed 4 years ago
Verified
7c1c90e79eaab69c611fbc154bd560fafedce065

Merge pull request #4 from debs-obrien/dependabot/npm_and_yarn/elliptic-6.5.3

ddebs-obrien committed 4 years ago
Verified
ce8e1b29105c014f4b626d224d180eaf40ffe751

Merge pull request #3 from debs-obrien/dependabot/npm_and_yarn/lodash-4.17.19

ddebs-obrien committed 4 years ago
Verified
e3925ad542ac217bd3eddf1825fff4467491c036

Bump elliptic from 6.5.2 to 6.5.3

ddependabot[bot] committed 4 years ago
Verified
74dd880ca43807be4d461bc454c8818b52b50550

Bump lodash from 4.17.15 to 4.17.19

ddependabot[bot] committed 4 years ago

README

The README file for this repository.

exit-plan

My get out of lockdown exit plan

This is a very simple example of how to use Hasura in your project to fetch data. Feel free to clone the project and change the GRAPHCMS_API which is located in the apollo/client-config folder for your own hasura endpoint. Then add your own data and modify the query if you change the table name or columns.

If you are new to Hasura it is really easy to get started.

For this example I have created a table called food with the following schema

Columns

  • id - uuid, primary key, unique, default: gen_random_uuid()
  • name - text
  • where - text
  • img - text
  • status - text, default: 'pending'::text
  • priority - integer

To add to an existing project

  • Install @nuxtjs/apollo
  • Add it to your build modules in the nuxt.config.js
  • Give apollo module options in the nuxt.config.js
apollo: {
// optional
errorHandler: '~/plugins/apollo-error-handler.js',
// required
clientConfigs: {
default: '~/apollo/client-configs/default.js'
}
},
  • Add a config file for apollo
mkdir apollo mkdir apollo/client-configs
touch apollo/client-configs/default.js
  • Add the following code inside remembering to replace the endpoint with the endpoint you get from Hasura
import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'

// Replace this with your project's endpoint
const GRAPHCMS_API = 'https://exit-lockdown.herokuapp.com/v1/graphql'

export default () => ({
  link: new HttpLink({ uri: GRAPHCMS_API }),
  cache: new InMemoryCache(),
  defaultHttpLink: false
})
  • Optional: In the plugins folder add an apollo-error-hander.js file
touch plugins/apollo-error-handler.js
/* eslint-disable no-console */
export default (error) => {
  console.log('Global error handler')
  console.error(error)
}
  • In your component add your query in within the script tags
import gql from 'graphql-tag'
export const food = gql`
  query {
    food {
      id
      img
      name
      priority
      status
      where
    }
  }
`
  • And add this below it
export default {
  data() {
    return {
      tableHeadings: ['What I miss', 'Place', 'Status', 'Priority'],
      food: []
    }
  },
  apollo: {
    $loadingKey: 'loading',
    food: {
      query: food
    }
  }
}

That's all you need. You should now have your Hasura endpoint and your application making a query to view the data which you can now display in your template. Have fun

Build Setup

# install dependencies
$ yarn

# serve with hot reload at localhost:3000
$ yarn dev

# build for production and launch server
$ yarn build
$ yarn start

# generate static project
$ yarn generate

For detailed explanation on how things work, check out Nuxt.js docs.