For fast prototyping next.js app with Hasura as backend Library is abstruction layer ower Hasura query api
1 Create dataSchema file, minimal example
export default {
user: {
id: { },
name: { },
email: { },
},
}
2 Fill internal library store with setDataSchema
import { setDataSchema } from 'lazy-gql'
import dataSchema from 'dataSchema'
setDataSchema(dataSchema)
3 Call one of build methods
lazy-gql-request for backend use example(with next.js api routes)
import { request } from 'lazy-gql-request'
import { buildInsert, setDataSchema } from 'lazy-gql'
import dataSchema from 'dataSchema'
setDataSchema(dataSchema)
const handler = async (req) => {
return await request(process.env.URL, { headers: { } })(buildInsert('users'), [{
name: 'random name',
email: 'random@email',
}])
}
export default handler
Set data schema you could on app instance initialization
import { setDataSchema } from 'lazy-gql'
import dataSchema from 'dataSchema'
setDataSchema(dataSchema)
For react application use hooks from lazy-gql-hooks
Also available support for react for builder lazy-gql-form
See examples at each package separately
export default {
user: {
id: { },
name: { },
email: { },
},
projects: {
name: { },
description: { }
},
flows: {
name: { },
}
}
return await request(process.env.URL)(buildQuery({
users: [{
projects: ['flows']
}]
}))
this renders gql query
query QueryUsers {
users {
id
name
email
projects {
name
description
flows {
name
}
}
}
}
all api methods have similar argument types - first is struct, second, variables more special info about each Hasura api methods
- buildQuery
- buildUpsert
- buildInsert
- buildUpdate
- buildDestroy
- buildSafeDestroy - is update with passed deleted_at timestamp