|
1 | 1 | === WPGraphQL Logging === |
2 | | -Contributors: wpengine |
| 2 | +Contributors: colin-murphy, joefusco, thdespou, wpengine |
3 | 3 | Tags: GraphQL, Headless, WPGraphQL, React, Rest, Logging, Performance, Debugging, Monitoring |
4 | 4 | Requires at least: 6.5 |
5 | | -Tested up to: 6.8,2 |
6 | | -Requires PHP: 8.1 |
| 5 | +Tested up to: 6.8.2 |
| 6 | +Requires PHP: 8.1.2 |
7 | 7 | Requires WPGraphQL: 2.3.0 |
8 | 8 | Stable tag: 0.1.0 |
9 | | -License: GPL-2.0 |
| 9 | +License: GPL-2.0-or-later |
10 | 10 | License URI: https://www.gnu.org/licenses/gpl-2.0.html |
11 | 11 |
|
| 12 | +A WPGraphQL logging plugin that provides visibility into the GraphQL request lifecycle, giving developers the observability needed to quickly identify and resolve bottlenecks in their headless WordPress application. |
| 13 | + |
12 | 14 | == Description == |
13 | 15 |
|
14 | | -A WPGraphQL logging plugin that provides visibility into request lifecycle to help quickly identify and resolve bottlenecks in your headless WordPress application. |
| 16 | +**WPGraphQL Logging** is a comprehensive logging solution for WPGraphQL that tracks and records GraphQL query execution, providing developers with detailed insights into query performance, errors, and request lifecycle events. |
15 | 17 |
|
16 | | -= Features = |
| 18 | +**Note:** This plugin is currently in BETA. While it is functional and ready for testing, some features may be subject to change based on community feedback. |
17 | 19 |
|
18 | | -- Query event lifecycle logging: |
19 | | - - Pre Request (`do_graphql_request`): logs query, variables, operation name |
20 | | - - Before Execution (`graphql_before_execute`): logs request params snapshot |
21 | | - - After Execution (`graphql_execute`): logs response, schema, request |
22 | | - - Before Response Returned (`graphql_return_response`): inspects response errors and upgrades level to Error when present |
| 20 | += Key Features = |
23 | 21 |
|
24 | | -- Pub/sub system: |
25 | | - - Subscribe with priorities, publish events, and apply transforms to mutate payloads |
26 | | - - WordPress bridges: `wpgraphql_logging_event_{event}` (action) and `wpgraphql_logging_filter_{event}` (filter) |
| 22 | +**GraphQL Request Lifecycle Logging** |
| 23 | +* Pre Request (`do_graphql_request`): Captures query text, variables, and operation name |
| 24 | +* Before Execution (`graphql_before_execute`): Records request parameter snapshot |
| 25 | +* After Execution (`graphql_execute`): Logs response data, schema context, and request details |
| 26 | +* Before Response (`graphql_return_response`): Inspects response for errors and automatically escalates log level when errors are present |
27 | 27 |
|
28 | | -- Monolog-based storage and context: |
29 | | - - Default handler writes to a WordPress table (`{$wpdb->prefix}wpgraphql_logging`) |
30 | | - - Processors include memory usage, web request, process ID, and GraphQL request details |
| 28 | +**Advanced Admin Interface** |
| 29 | +* View and filter all logged GraphQL requests in the WordPress admin |
| 30 | +* Search and sort by date, query name, log level, or custom criteria |
| 31 | +* Export logs to CSV for offline analysis |
| 32 | +* Configurable data retention policies with automatic cleanup |
| 33 | + |
| 34 | +**Flexible Event System** |
| 35 | +* Built-in pub/sub architecture for subscribing to logging events |
| 36 | +* Priority-based event handling |
| 37 | +* Transform and mutate log payloads before storage |
| 38 | +* WordPress action/filter bridges: `wpgraphql_logging_event_{event}` and `wpgraphql_logging_filter_{event}` |
| 39 | + |
| 40 | +**Powerful Storage & Context** |
| 41 | +* Built on Monolog for reliable, industry-standard logging |
| 42 | +* Default database handler stores logs in WordPress table (`{$wpdb->prefix}wpgraphql_logging`) |
| 43 | +* Extensible processor system includes: |
| 44 | + * Memory usage tracking |
| 45 | + * Web request context |
| 46 | + * Process ID tracking |
| 47 | + * GraphQL-specific request metadata |
| 48 | + |
| 49 | +**Customization Options** |
| 50 | +* Add custom log processors via filters |
| 51 | +* Implement custom storage handlers |
| 52 | +* Define custom logging rules and conditions |
| 53 | +* Extend the admin interface with custom fields and tabs |
| 54 | + |
| 55 | += Use Cases = |
| 56 | + |
| 57 | +* **Performance Monitoring**: Identify slow queries and execution bottlenecks |
| 58 | +* **Error Tracking**: Monitor and debug GraphQL errors in production |
| 59 | +* **Development & Testing**: Track query behavior during development |
| 60 | +* **Compliance & Auditing**: Maintain records of API access and usage |
| 61 | +* **Analytics**: Analyze query patterns and usage trends |
| 62 | + |
| 63 | += Requirements = |
| 64 | + |
| 65 | +* WordPress 6.5 or higher |
| 66 | +* PHP 8.1.2 or higher |
| 67 | +* WPGraphQL 2.3.0 or higher |
| 68 | + |
| 69 | += Documentation = |
| 70 | + |
| 71 | +For detailed documentation, guides, and examples, visit the [GitHub repository](https://github.com/wpengine/hwptoolkit/tree/main/plugins/wpgraphql-logging). |
| 72 | + |
| 73 | +== Installation == |
| 74 | + |
| 75 | +1. Upload the plugin files to `/wp-content/plugins/wpgraphql-logging/`, or install the plugin through the WordPress plugins screen directly |
| 76 | +2. Activate the plugin through the 'Plugins' screen in WordPress |
| 77 | +3. Navigate to Settings > WPGraphQL Logging in the WordPress admin to configure settings |
| 78 | +4. View logged queries can be found in GraphQL Logs |
31 | 79 |
|
32 | | -== Upgrade Notice == |
33 | 80 | == Frequently Asked Questions == |
| 81 | + |
| 82 | += Is this plugin production-ready? = |
| 83 | + |
| 84 | +This plugin is currently in BETA. It is functional and ready for testing in staging environments. We recommend thorough testing before deploying to production. |
| 85 | + |
| 86 | += Does this plugin affect GraphQL query performance? = |
| 87 | + |
| 88 | +The plugin is designed to have minimal performance impact. Logging operations are performed asynchronously where possible, and you can configure data retention policies to manage database size. |
| 89 | + |
| 90 | += Can I export my logs? = |
| 91 | + |
| 92 | +Yes! The admin interface includes CSV export functionality for all filtered log entries. |
| 93 | + |
| 94 | += Can I customize what gets logged? = |
| 95 | + |
| 96 | +Yes, the plugin provides extensive hooks and filters to customize logging behavior, add custom processors, and implement custom storage solutions. |
| 97 | + |
| 98 | += How do I delete old logs? = |
| 99 | + |
| 100 | +The plugin includes configurable data retention settings. You can set automatic cleanup rules to delete logs older than a specified number of days. |
| 101 | + |
34 | 102 | == Screenshots == |
| 103 | + |
| 104 | +1. View all GraphQL query logs with filtering and search |
| 105 | +2. Detailed log entry view showing query, variables, and response |
| 106 | +3. Configuration settings for data retention and logging behavior |
| 107 | +4. Export logs to CSV for analysis |
| 108 | + |
35 | 109 | == Changelog == |
| 110 | + |
| 111 | += 0.1.0 - 2025-01-22 = |
| 112 | +* Initial BETA release |
| 113 | +* Core logging functionality for WPGraphQL request lifecycle |
| 114 | +* Admin interface for viewing and filtering logs |
| 115 | +* CSV export functionality |
| 116 | +* Configurable data retention and cleanup |
| 117 | +* Extensible event system with pub/sub architecture |
| 118 | +* Monolog-based storage with custom processors |
| 119 | + |
| 120 | +== Upgrade Notice == |
| 121 | + |
| 122 | += 0.1.0 = |
| 123 | +Initial BETA release. |
| 124 | + |
| 125 | +== Support == |
| 126 | + |
| 127 | +For support, feature requests, or bug reports, please visit our [GitHub issues page](https://github.com/wpengine/hwptoolkit/issues). |
0 commit comments