Proactive feedback

Note: Learn how to send some custom output in the response, in guide Hooking into Proactive feedback (guide coming soon)

Use the top-level entry extensions to send data concerning deprecations, warnings, logs, notices and traces in the response to the query.

Any resolver (for fields and directives) can log any piece of information. This is useful to inform the user about some upcoming change to the schema through a notice, provide the developer with performance analysis through tracing, and others.

Deprecations permalink

Deprecations are returned in the same query involving deprecated fields, and not only when doing introspection.

Warnings permalink

Warning are issues which can be considered non-blocking, i.e. they enhance the query but do not break it. While in standard GraphQL they would be considered errors, the GraphQL API for WordPress takes a more lenient approach towards them, by ignoring their execution only, and not the whole query.

For instance, passing parameter limit with the wrong type will not stop execution of the query, it will just ignore this parameter (hence, the response will bring more results that are needed, but that's not a breaking issue) and provide an appropriate warning message.

Similarly, passing fields arguments which have not been added to the schema is considered a warning, and not an error.

Logs permalink

Execute this query twice within 10 seconds, to observe a log entry indicating that the field is being retrieved from the cache:

Traces permalink

This query traces how much time the field takes to resolve:

Notices permalink

Example to be provided via extension plugin "Schema Feedback" (WIP).

Share on 🐦 Twitter | πŸ‘ŽπŸΎ Facebook