This repository contains GraphQL schema and TypeScript types for the dictyBase API.
All schema, queries and mutations are inside the src
folder. The schema
folder contains the graphql schema definitions. The mutations
and
queries
folders has the graphql documents.
yarn add dictybase/dicty-graphql-schema
To install a particular version (check tags/release first)
yarn add dictyBase/dicty-graphql-schema#v1.0.0
The code generated by the graphql-codegen plugins can be used in the following ways
Generates base Typescript
types which are used as base types for other
plugins. Details
here
Generates types for graphql documents: Query
, Mutation
etc. Details
here
Generated typed react hooks for every graphql opertation in the documents. For example, the following hook can be used get a list of strain from our graphql API.
import {useStrainListQuery} from "dictybase/dicty-graphql-schema"
export const MyStrainComponent = () => {
const { data, loading, error } = useStrainListQuery({ variables: { limit }})
......
return (
<div>{data}</div>
....
)
}
Details here
Details here
The generated code should be used with apollo-clientv3, particularly in case of configuring cache. For example,
import { InMemoryCache } from '@apollo/client'
// generated by Fragment Matcher plugin
import {PossibleTypesResultData} from "dictybase/dicty-graphql-schema/fragment"
const cache = new InMemoryCache({ possibleTypes: PossibleTypesResultData.possibleTypes })
Details here
Generates fully-typed keyFields and Type-Policies for apollo-client. It can be imported like this ...
import {XXXXXXX} from "dictybase/dicty-graphql-schema/apollo-client-helpers"
Details here.
Generates msw based typed mock handlers for graphql API. The handlers can be imported like this....
import {handlerxxxxx} from "dictybase/dicty-graphql-schema/mocks"
Details here
Generates a json formatted graphql introspection file saves as schema.json
.
Details
here
Details here
- Clone the repository.
- Create a new branch (i.e.
feature/new-schema
). - Install bun
- Run
bun install
- Complete any necessary work.
- Run
bun run --bun generat
to generate code from the schema. The generated code will go in thetypes
folder. - Commit all changes and create a github pull request.
- Repeat the cycle until the work is done. When finished, merge to
develop
.
- If you are ready to cut a new release, merge(rebase)
develop
intomain
. - Install nsv.
- Run
nsv next
to determine the version. - Then run
gh release create
to create a new release using the version no as a tag.