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

Support mocking the API #3

Open
youknowriad opened this issue Jul 21, 2020 · 2 comments
Open

Support mocking the API #3

youknowriad opened this issue Jul 21, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@youknowriad
Copy link
Owner

Some blocks depend on the WP API, it would be great to be able to mock the API to preview these blocks in isolation.

@youknowriad youknowriad added the enhancement New feature or request label Jul 21, 2020
@leoloso
Copy link

leoloso commented Jul 23, 2020

To have in consideration: mocking should hopefully work with any API, not only with the WP REST API.

In my case, I use GraphQL to fetch data for my blocks, executing a GraphQL query over POST (some example queries here, and the fetch is executed here)

@youknowriad
Copy link
Owner Author

youknowriad commented Jul 23, 2020

Most blocks rely on wp.apiFetch to perform the API requests, so it seems like a good candidate to mocking APIs. Right now, it's already possible to do so by registering a custom middleware. We can try to make it more user-friendly and document it.

For APIs not relying on wp.apiFetch, I think you should check if the library you're using allows interceptors, most generally do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants