Headless Live Preview with Gatsby I am following Andrew Welch's post here - https://twitter.com/nystudio107/status/1168220713158942720?lang=en

I used the gatsby-config.js file he shared here - https://gist.github.com/monachilada/af7e92a86e0d27ba47a8597ac4e4b105

However, when I edit fields in the Live Preview, I get the following error:

UNHANDLED REJECTION Schema must contain uniquely named types but contains multiple types named "Craft".

    const { createHttpLink } = require('apollo-link-http');
    const fetch = require('node-fetch');
    const store = require('store');
    const sourceNodes = require('gatsby/dist/utils/source-nodes');
    require('dotenv').config();

    const craftGqlUrl = process.env.CRAFT_GQL_URL;
    const craftGqlToken = process.env.CRAFT_GQL_TOKEN;

    module.exports = {
      plugins: [
        {
          resolve: 'gatsby-source-graphql',
          options: {
            typeName: 'Craft',
            fieldName: 'craft',
            createLink: () =&gt;
              createHttpLink({
                uri: `${craftGqlUrl}`,
                headers: {
                  Authorization: `Bearer ${craftGqlToken}`,
                },
                fetch: (uri, options) =&gt; {
                  const token = store.get('X-Craft-Token');
                  return fetch(
                    `${uri}${token !== undefined ? `?token=${token}` : ''}`,
                    options,
                 );
                },
              }),
          },
        },
      ],
      developMiddleware: app =&gt; {
        app.use('*', (req, res, next) =&gt; {
          if (req.query.token) {
            store.set('X-Craft-Token', req.query.token);
            sourceNodes();
          }
          next();
        });
      },
    };


Any ideas?

Thanks
they updated the sourceNodes cycle since this config, you will need to update the schema first doing something like this:

An example using the body hook if you need it:

createSchemaCustomization({ refresh: true }).then(() =&gt; {
    sourceNodes({ webhookBody });
});