@northernv/graphql
v1.0.1
Published
A framework for graphql processing
Downloads
5
Readme
@northernv/graphql
Usage
npm install -S @northernv/graphql;
yarn add @northernv/graphql;
Schema for ...
Schema
- Queries and Mutations are in
queries.gql
- Types are in
types.gql
Templates
The client query/mutation/fragments are held in /t
. These are used directly by the server when creating contract (integration) tests for the various GQL methods.
Client GQL files
Run the npm run build
file to generate the frontend GQL files.
/static
Files ready to be consumed by React/Vue when using Apollo GraphQL loader
Usage
In Webpack
loaders: [
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
}
]
In the file
import Unit from '@northernv/vgql/static/unit.gql'
const { data, errors } = await this.$apollo.query({
query: Unit,
variables: {
input: { ... },
}
})
/json
Files ready to be consumed by Apollo, no need for graphql-tag
Usage
import Unit from '@northernv/vgql/json/unit'
const { data, errors } = await this.$apollo.query({
query: Unit,
variables: {
input: { ... },
}
})
/gql
Files used with graphql-tag
Usage
import Unit from '@northernv/vgql/gql/unit'
import gql from 'graphql-tag'
const { data, errors } = await this.$apollo.query({
query: gql`Unit`,
variables: {
input: { ... },
}
})
Directives
@timestamp
: AddscreatedAt
,updatedAt
,deletedAt
properties to typestimestamp-directive.js
In your models, that are Javascript classes, include a static function calledloaders
that returns an object of dataloaders