StellateHQ / fuse

Fuse: The fastest way to build and query great APIs with TypeScript

Home Page:https://fusedata.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: First class mocking support

JoviDeCroock opened this issue · comments

Summary

Currently we have a documentation page around mocking fields/entities that aren't implemented yet, we could take this further by integrating faker.js we could make this as easy as adding { mock: 'phoneNumber' } or something similar which would mock the value when there isn't one present on the payload.

Proposed Solution

We extend the pothos field builder API with a mock option that integrates faker, when no value is present we invoke the faker method and mock the value.

For this feature, how do you see specific field mock or relations? How it will be handled in the node so it is easy to remove or add?

Not sure what you mean here, my vision of this would be to do the following

  fields: (t) => ({
    myFieldInDevelopment: t.exposeString('cityName', { mock: 'cityName' })
  }),

Where behind the scenes the resolver would check whether cityName is present on the retrieved data, if not it would fallback to the mock.