Last active
October 21, 2021 22:01
-
-
Save jasonbahl/6e3037fd8ebde4a7aca703d5e0a29499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { hooks } = wpGraphiQL; | |
import LZString from 'lz-string' | |
hooks.addFilter( 'graphiql_after_graphiql', 'wp-graphiql-extension', (res, props) => { | |
const encoded = LZString.compressToEncodedURIComponent(props.query) | |
const decoded = LZString.decompressFromEncodedURIComponent(encoded) | |
res.push( | |
<div style={{maxWidth: `200px`}}> | |
<h2>Encoded</h2> | |
<pre>{encoded}</pre> | |
<br/> | |
<h2>Decoded</h2> | |
<pre>{decoded}</pre> | |
</div> | |
) | |
return res | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This shows how to filter in a panel to GraphiQL to debug the query encoding/decoding