Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.13 KB

development.md

File metadata and controls

53 lines (41 loc) · 1.13 KB

Development

  • Use the node version defined in .nvmrc

    $ nvm use || nvm install
  • Update npm dependencies

    $ pnpm install
  • Write custom query or mutations in .graphql files in the folder or any subfolder of graphql/. For example, graphql/query/getPostsById.query.graphql:

    query GetPostById($id: ID!) {
        post(id: $id) {
            id
            title
            body
        }
    }
  • Run codegen in shell

    pnpm codegen
  • Use the generated typed-documents, query types and variable types in the graphql/generated.ts with urql. For example, pages/test-graphql.tsx:

    import { useQuery } from 'urql';
    import {
        GetPostByIdDocument,
        GetPostByIdQuery,
        GetPostByIdQueryVariables,
    } from 'graphql/generated';
    
    // ...
    const [result] = useQuery<GetPostByIdQuery, GetPostByIdQueryVariables>({
        query: GetPostByIdDocument,
        variables: {
            id: '1',
        },
    });
    // ...
  • Write tests in __tests__ folder with filename *.test.ts(x)