@cobbl/graphql-codegen-typescript-operations-tester
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

graphql-codegen-operations-safelist · Version Tests codecov Gitmoji lerna

Install

npm i -D @graphql-codegen/typescript @graphql-codegen/typescript-operations @cobbl/graphql-codegen-typescript-operations-tester

Example

codegen.yml

schema: './schema.graphql'
documents: './documents.graphql'

generated/tests.ts:
  plugins:
    - typescript
    - typescript-operations
    - '@cobbl/graphql-codegen-typescript-operations-tester'
  config:
    prefix: test # optional | default 'test'

schema.graphql

type Author {
  firstname: String
  lastname: String
  fullname: String
}

type Book {
  title: String
  author: Author
}

type Query {
  books: [Book]
}

documents.graphql

query getBooks($var1: String!) {
  books(var1: $var1) {
    title
    author {
      firstname
      lastname
      fullname
    }
  }
}

test.spec.ts

import { testGetBooksQuery } from './generated/tests.ts'
import { schema } from 'path/to/my/schema'

describe('Test something cool', () => {
  it('testGetBooksQuery should return something', async () => {
    const res = await testGetBooksQuery({ schema }, { var1: 'hello' })
    expect(res.data?.books).toBeAwesome()
  })
})

Readme

Keywords

none

Package Sidebar

Install

npm i @cobbl/graphql-codegen-typescript-operations-tester

Weekly Downloads

0

Version

0.1.1

License

none

Unpacked Size

17.5 kB

Total Files

11

Last publish

Collaborators

  • heiso