Skip to content

v0.4.0

Compare
Choose a tag to compare
@kettanaito kettanaito released this 29 Jun 10:00

Features

  • Adds a .toSchema() method on a model factory to generate a GraphQL schema (#96).
import { factory, primaryKey } from '@mswjs/data'

const db = factory({
  user: {
    id: primaryKey(() => 'abc-123')
  }
})

const graphqlSchema = db.toSchema()
  • Numbers can be used as primary keys.

  • Supports filtering entities by their properties in request query parameters (#69):

import { setupServer } from 'msw/node'
import { factory, primaryKey } from '@mswjs/data'

const db = factory({
  user: {
    id: primaryKey(() => 'abc-123')
  }
})

const server = db.user.toHandlers('rest')
fetch('/users?id=abc-123')

Bug fixes

  • Fixes an issue when dropping a database and referencing a db.*.getAll() on a model that had a relational property raised an exception (#101).