packages/gatsby-source-wordpress/src/steps/preview/preview.md
WPGraphQL >= v0.15.0WPGatsby >= v0.6.0gatsby-source-wordpress. This means pointing the url plugin option for that source plugin at your WordPress instance's /graphql endpoint.preview: true (the source plugin uses this to tell wether or not previews are being sourced)sourceNodes as a refresh is invoked via the refresh webhook and the source plugin detects this and invokes sourcePreviews instead of sourcing nodes.RECEIVED_PREVIEW_DATA_FROM_WRONG_URL is sent back to WPGatsby for processing.onCreatePage,
onCreatepageSavePreviewNodeIdToPageDependency which (in preview mode) stores up a map of node id's to pages created from them. In order to make this performant enough, WPGatsby Preview has a requirement that there's a node id in the pageContext of any page created in Gatsby that should be previewable. The node id in pageContext is used to create the nodeId → page map.onCreatePageRespondToPreviewStatusQuery This function checks if the currently created page's node has a preview status callback assigned to it. If it does it invokes the callback with a PREVIEW_SUCCESS status type, sending the preview status back to WPGatsby. After invoking it, the callback is removed from the internal store so that it can't be called again.onPreExtractQueries we check for any leftover callbacks which haven't been invoked earlier during onCreatePage. Any that haven't been invoked are not previewable. This is either because the created page didn't have a node id in pageContext, or because no page was created for the node being previewed. These leftover callbacks are invoked with a NO_PAGE_CREATED_FOR_PREVIEWED_NODE status and WPGatsby processes this status and displays steps on how to debug & fix.runSteps any existing callbacks are invoked with a GATSBY_PREVIEW_PROCESS_ERROR status. A very generic error about which step the detailed error occurred in is passed along to WPGatsby on the context property of the callback. WPGatsby displays this generic error and encourages the user to check their preview logs.asPreview api from WPGraphQL and updates the Gatsby node. If a page is created as a result of this, the above onCreatePage logic will run which will in turn update the preview status in WPGatsby.204 or 200 status, we optimistically try to load the preview ui and so display a Gatsby branded loading indicator. If the webhook returned another status, we show an error about the Gatsby Preview instance being offline. In both cases, we do a second in-browser check to see if the Preview instance really is online or offline. The reason for this is the webhook will not always be hit when the preview window is loaded or re-loaded. So the Preview instance could come online or offline in the meantime.PREVIEW_SUCCESS) the error will be displayed and the loading icon animation will be removed.PREVIEW_SUCCESS status is received (along with the path the preview can be viewed at), the iframe will be updated to point to the preview frontend url + path. Once the iframe emits it's loaded event, the loader will be removed, unveiling the preview via the Gatsby Preview site.gatsby develop. Now whenever an action is received from WPGatsby, the source plugin will diff the schemas. If they're different, it will re-run createSchemaCustomization which will fetch the updated schema and update the Gatsby queries. This means you don't need to re-start Preview or gatsby develop when updating your remote schema!