Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: First class mocking support #75

Open
JoviDeCroock opened this issue Dec 7, 2023 · 2 comments
Open

RFC: First class mocking support #75

JoviDeCroock opened this issue Dec 7, 2023 · 2 comments
Labels
RFC A discussion about a future feature

Comments

@JoviDeCroock
Copy link
Contributor

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.

@JoviDeCroock JoviDeCroock added the RFC A discussion about a future feature label Dec 7, 2023
@b-barry
Copy link

b-barry commented Dec 14, 2023

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?

@JoviDeCroock
Copy link
Contributor Author

JoviDeCroock commented Dec 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC A discussion about a future feature
Projects
None yet
Development

No branches or pull requests

2 participants