Giter VIP home page Giter VIP logo

gatsby-source-prismic-graphql's Introduction

gatsby-source-prismic-graphql

A Gatsby plugin for fetching source data from the Prismic headless CMS using Prismic's beta GraphQL API. This plugin provides full support for Prismic's preview feature out of the box.

For more context, be sure to checkout Prismic's getting started guide: Using Prismic With Gatsby. This README, however, serves as the most-up-to-date source of information on gatsby-source-prismic-graphql's latest developments and breaking changes.

Please be sure your Prismic repository has the GraphQL API enabled. It is enabled by default on all new Prismic repositories. If you have an older repository or are unable to access https://[your_repo].prismic.io/graphql, please reach out to Prismic support to request the GraphQL API.

Contents

Differences From gatsby-source-prismic

gatsby-source-prismic-graphql (this plugin) fetches data using Prismic's beta GraphQL API and provides full support for Prismic's Preview feature out of the box. It also provides an easy-to-configure interface for page generation.

gatsby-source-prismic is a different plugin that fetches data using Prismic's REST and Javascript APIs. Previews must be coded up separately.

Getting Started

Install the plugin

npm install --save gatsby-source-prismic-graphql

or

yarn add gatsby-source-prismic-graphql

Add plugin to gatsby-config.js and configure

{
  resolve: 'gatsby-source-prismic-graphql',
  options: {
    repositoryName: 'gatsby-source-prismic-test-site', // required
    defaultLang: 'en-us', // optional, but recommended
    accessToken: '...', // optional
    prismicRef: '...', // optional, default: master; useful for A/B experiments
    path: '/preview', // optional, default: /preview
    previews: true, // optional, default: true
    pages: [{ // optional
      type: 'Article', // TypeName from prismic
      match: '/article/:uid', // pages will be generated under this pattern
      previewPath: '/article', // optional path for unpublished documents
      component: require.resolve('./src/templates/article.js'),
      sortBy: 'date_ASC', // optional, default: meta_lastPublicationDate_ASC; useful for pagination
    }],
    extraPageFields: 'article_type', // optional, extends pages query to pass extra fields
    sharpKeys: [
      /image|photo|picture/, // (default)
      'profilepic',
    ],
  }
}

Edit your gatsby-browser.js

const { registerLinkResolver } = require('gatsby-source-prismic-graphql');
const { linkResolver } = require('./src/utils/linkResolver');

registerLinkResolver(linkResolver);

Usage

Automatic Page Generation

You can generate pages automatically by providing a mapping configuration under the pages option in gatsby-config.js.

Let's assume we have the following page configuration set:

{
  pages: [{
    type: 'Article',
    match: '/blogpost/:uid',
    previewPath: '/blogpost',
    component: require.resolve('./src/templates/article.js'),
  }],
}

If you have two blog posts with UIDs of foo and bar, the following URL slugs will be generated:

  • /blogpost/foo
  • /blogpost/bar

If you create a new unpublished blogpost, baz it will be accessible for preview under, assuming you've established a preview session with Prismic:

  • /blogpost?uid=baz

More on Prismic Previews below.

Conditionally generating pages

If the default page generation doesn't cover your use-case, you can provide an optional filter option to your individual page configurations.

For example, if you had a single Prismic Article type and wanted pages with music in their UIDs to be generated at a different URL :

{
  pages: [{
    type: 'Article',
    match: '/musicblog/:uid',
    filter: data => data.node._meta.uid.includes('music'),
    previewPath: '/blogposts',
    component: require.resolve('./src/templates/article.js'),
  }, {
    type: 'Article',
    match: '/blog/:uid',
    filter: data => !data.node._meta.uid.includes('music'),
    previewPath: '/blogposts',
    component: require.resolve('./src/templates/article.js'),
  }],
}

Given 3 articles with UIDs of why-i-like-music, why-i-like-sports and why-i-like-food, the following URL slugs will be generated:

  • /musicblog/why-i-like-music
  • /blog/why-i-like-sports
  • /blog/why-i-like-food

Generating pages from page fields

Sometimes the meta provided by default doesn't contain enough context to be able to filter pages effectively. By passing extraPageFields to the plugin options, we can extend what we can filter on.

{
  extraPageFields: 'music_genre',
  pages: [{
    type: 'Article',
    match: '/techno/:uid',
    filter: data => data.node.music_genre === 'techno',
    previewPath: '/blogposts',
    component: require.resolve('./src/templates/article.js'),
  }, {
    type: 'Article',
    match: '/acoustic/:uid',
    filter: data => data.node.music_genre === 'acoustic',
    previewPath: '/blogposts',
    component: require.resolve('./src/templates/article.js'),
  }]
}

Given 2 articles with the music_genre field set, we'll get the following slugs:

/techno/darude /acoustic/mik-parsons

Support for Multiple Languages

Prismic allows you to create your content in multiple languages. This library supports that too. When setting up your configuration options in gatsby-config.js, there are three optional properties you should be aware of: options.defaultLang, options.langs, and options.pages[i].langs. In the following example, all are in use:

{
  resolve: 'gatsby-source-prismic-graphql',
  options: {
    repositoryName: 'gatsby-source-prismic-test-site',
    defaultLang: 'en-us',
    langs: ['en-us', 'es-es', 'is'],
    path: '/preview',
    previews: true,
    pages: [{
      type: 'Article',
      match: '/:lang?/:uid',
      previewPath: '/article',
      component: require.resolve('./src/templates/article.js'),
      sortBy: 'date_ASC',
      langs: ['en-us', 'es-es', 'is'],
    }, {
      type: "Noticias",
      match: '/noticias/:uid',
      previewPath: '/noticias',
      component: require.resolve('./src/templates/noticias.js'),
      sortBy: 'date_ASC',
      langs: ['es-es'],
    }],
  }
}

In the example above, pages are generated for two document types from Prismic--Articles and Noticias. The latter consists of news stories in Spanish. There are three languages total in use in this blog: US English, Traditional Spanish and Icelandic.

For Articles, we are instructing the plugin to generate pages for articles of all three languages. But, because there is a question mark (?) after the :lang portion of the match property (/:lang?/:uid), we only include the locale tag in the URL slug for languages that are not the defaultLang specified above (i.e., 'en-us'). So for the following languages, these are the slugs generated:

  • US English: /epic-destinations
  • Spanish: /es-es/destinos-increibles
  • Icelandic: /is/reykjadalur

If we had not specified a defaultLang, the slug for US English would have been /en-us/epic-destinations. And, in fact, including the langs: ['en-us', 'es-es', 'is'] declaration for this particular document type (Articles) is unnecessary because we already specified that as the default language set right after defaultLang in the plugin options.

For Noticias, however, we only want to generate pages for Spanish documents of that type (langs is [es-es]). We decide that in this context, no locale tag is needed in the URL slug; "noticias" is already enough indication that the contents are in Spanish. So we omit the :lang match entirely and specify only match: '/noticias/:uid'.

This is an example of how these three properties can be used together to offer maximum flexibility. To see this in action, check out the languages example app.

(Optional) Short language codes

To use short language codes (e.g. /fr/articles) instead of the default (e.g. /fr-fr/articles), you can set options.shortenUrlLangs to true.

Keep in mind that if you use this option & have multiple variants of a language (e.g. en-us and en-au) that would be shortened to the same value, you should add UIDs to your URLs to differentiate them.

Page Queries: Fetch Data From Prismic

It is very easy to fetch data from Prismic in your pages:

import React from 'react';
import { RichText } from 'prismic-reactjs';

export const query = graphql`
  {
    prismic {
      page(uid:"homepage", lang:"en-us") {
        title
        description
      }
    }
  }
`

export default function Page({ data }) => <>
  <h1>{RichText.render(data.prismic.title)}</h1>
  <h2>{RichText.render(data.prismic.description)}</h2>
</>

Prismic Previews

Previews are enabled by default, however they must be configured in your prismic instance/repository. For instructions on configuring previews in Prismic, refer to Prismic's guide: How to set up a preview.

When testing previews, be sure you are starting from a valid Prismic preview URL/path. The most reliable way to test previews is by using the preview button from your draft in Prismic. If you wish to test the Preview locally, catch the URL that opens immediately after clicking the preview link:

https://[your-domain.tld]/preview?token=https%3A%2F%[your-prismic-repo].prismic.io%2Fpreviews%2FXRag6xAAACA...ABwjduaa%3FwebsitePreviewId%3DXRA...djaa&documentId=XRBH...jduAa

Then replace the protocol and domain at the beginning of the URL with your localhost:PORT instance, or wherever you're wanting to preview from.

This URL will be parsed and replaced by the web app and browser with the proper URL as specified in your page configuration.

StaticQuery and useStaticQuery

You can use StaticQuery as usual, but if you would like to preview them, you must use the withPreview function.

See the example

import { StaticQuery, graphql } from 'gatsby';
import { withPreview } from 'gatsby-source-prismic-graphql';

const articlesQuery = graphql`
  query {
    prismic {
      ...
    }
  }
`;

export const Articles = () => (
  <StaticQuery
    query={articlesQuery}
    render={withPreview(data => { ... }, articlesQuery)}
  />
);

useStaticQuery is not yet supported.

Fragments

Fragments are supported for both page queries and static queries.

See the example

Within page components:

import { graphql } from 'gatsby';

const fragmentX = graphql` fragment X on Y { ... } `;

export const query = graphql`
  query {
    ...X
  }
`;

const MyPage = (data) => { ... };
MyPage.fragments = [fragmentX];

export default MyPage;

With StaticQuery:

import { StaticQuery, graphql } from 'gatsby';
import { withPreview } from 'gatsby-source-prismic-graphql';

const fragmentX = graphql` fragment X on Y { ... } `;

export const query = graphql`
  query {
    ...X
  }
`;

export default () => (
  <StaticQuery
    query={query}
    render={withPreview(data => { ... }, query, [fragmentX])}
  />
);

Dynamic Queries and Fetching

You can use this plugin to dynamically fetch data for your component using prismic.load. Refer to the pagination example to see it in action.

import React from 'react';
import { graphql } from 'gatsby';

export const query = graphql`
  query Example($limit: Int) {
    prismic {
      allArticles(first: $limit) {
        edges {
          node {
            title
          }
        }
      }
    }
  }
`;

export default function Example({ data, prismic }) {
  const handleClick = () =>
    prismic.load({
      variables: { limit: 20 },
      query, // (optional)
      fragments: [], // (optional)
    });

  return (
    // ... data
    <button onClick={handleClick}>load more</button>
  );
}

Pagination

Pagination can be accomplished statically (i.e., during initialy page generation) or dynamically (i.e., with JS in the browser). Examples of both can be found in the pagination example.

Prismic pagination is cursor-based. See Prismic's Paginate your results article to learn about cursor-based pagination.

By default, pagination will be sorted by last publication date. If you would like to change that, specify a sortBy value in your page configuration in gatsby-config.js.

Dynamically-Generated Pagination

When coupled with prismic.load, as demonstrated in the index page of the pagination example, other pages can be fetched dynamically using page and cursor calculations.

GraphQL documents from Prismic have a cursor--a base64-encoded string that represents their order, or page number, in the set of all documents queried. We provide two helpers for converting between cursor strings and page numbers:

  • getCursorFromDocumentIndex(index: number)
  • getDocumentIndexFromCursor(cursor: string)

Statically-Generated Pagination

Basic Pagination

For basic linking between the pages, metadata for the previous and next pages are provided to you automatically via pageContext in the paginationPreviousMeta and paginationNextMeta properties. These can be used in conjunction with your linkResolver to generate links between pages without any additional GraphQL query. For an example of this, take a look at the <Pagination /> component in the pagination example's article.js.

Enhanced Pagination

If you would like to gather other information about previous and next pages (say a title or image), simply modify your page query to retrieve those documents. This also is demonstrated in the same pagination example with the <EnhancedPagination /> component and the page's GraphQL query.

Working with gatsby-image

The latest versions of this plugin support gatsby-image by adding a new property to GraphQL types that contains fields that match the sharpKeys array (this defaults to /image|photo|picture/) to the Sharp suffix.

Note: When querying, make sure to also query the source field. For example:

query {
  prismic {
    Article(id: "123") {
      title
      articlePhoto
      articlePhotoSharp {
        childImageSharp {
          fluid(maxWidth: 400, maxHeight: 250) {
            ...GatsbyImageSharpFluid
          }
        }
      }
    }
  }
}

You can also get access to specific crop sizes from Prismic by passing the crop argument:

query {
  prismic {
    Author(id: "123") {
      name
      profile_picture
      profile_pictureSharp(crop: "face") {
        childImageSharp {
          fluid(maxWidth: 500, maxHeight: 500) {
            ...GatsbyImageSharpFluid
          }
        }
      }
    }
  }
}

NOTE Images are not transformed in preview mode, so be sure to fall back to the default image when the sharp image is null.

import Img from 'gatsby-image';
import get from 'lodash/get';

// ...

const sharpImage = get(data, 'prismic.Author.profile_pictureSharp.childImageSharp.fluid');
return sharpImage ? (
  <Img fluid={sharpImage} />
) : (
  <img src={get(data, 'prismic.Author.profile_picture.url')} />
);

Later, we may add an Image component that does this for you and leverages the new Prismic Image API as a fallback for preview modes.

Prismic.io Content A/B Experiments Integration

You can use this plugin in combination with Prismic's built-in experiments functionality, and a hosting service like Netlify, to run content A/B tests.

Experiments in Prismic are basically branches of the core content, split into 'refs' similar to git branches. So if you want to get content from a certain experiment variation, you can pass the corresponding ref through to Prismic in your request, and it will return content based on that ref's variation.

A/B experiments are tricky to implement in a static website though; A/B testing needs a way to dynamically serve up the different variations to different website visitors. This is at odds with the idea of a static, non-dynamic website.

Fortunately, static hosting providers like Netlify allow you to run A/B tests at a routing level. This makes it possible for us to build multiple versions of our project using different source data, and then within Netlify split traffic to our different static variations.

Therefore, we can use A/B experiments from Prismic in the following way:

  1. Setup an experiment in Prismic.

  2. Create a new git branch of your project which will be used to get content. You will need to create a separate git branch for each variation.

  3. In that git branch, edit/add the optional 'prismicRef' parameter (documented above). The value of this should be the ref of the variation this git branch is for.

  4. Push the newly created branch to your git repo.

  5. Now go to your static hosting provider (we'll use Netlify in this example), and setup split testing based on your git branches/Prismic variations.

  6. Now your static website will show different experimental variations of the content to different users! At this point the process is manual and non-ideal, but hopefully we'll be able to automate it more in the future.

How This Plugin Works

  1. The plugin creates a new page at /preview (by default, you can change this), that will be your preview URL you setup in the Prismic admin interface.

    It will automatically set cookies based on the query parameters and attempt to find the correct page to redirect to with your linkResolver.

  2. It uses a different babel-plugin-remove-graphql-queries on the client.

    The modified plugin emits your GraphQL queries as a string so they can be read and re-used on the client side by the plugin.

  3. Once redirected to a page with the content, everything will load normally.

    In the background, the plugin takes your original Gatsby GraphQL query, extracts the Prismic subquery and uses it to make a GraphQL request to Prismic with a preview reference.

    Once data is received, it will update the data prop with merged data from Prismic preview and re-render the component.

Development

git clone [email protected]:birkir/gatsby-source-prismic-graphql.git
cd gatsby-source-prismic-graphql
yarn install
yarn setup
yarn start

# select example to work with
cd examples/default
yarn start

Issues and Troubleshooting

Please raise an issue on GitHub if you have any problems.

My page GraphQL query does not hot-reload for previews

This is a Gatsby limitation. You can bypass this limitation by adding the following:

export const query = graphql` ... `;
const MyPage = () => { ... };

MyPage.query = query; // <-- set the query manually to allow hot-reload.

gatsby-source-prismic-graphql's People

Contributors

andyto avatar ardeois avatar arnaudlewis avatar birkir avatar bostrom avatar braican avatar brandonfancher avatar bwlt avatar dependabot[bot] avatar douglasnomizo avatar duaner avatar greatwitenorth avatar jamesisaac avatar jdwillemse avatar matt-sanders avatar mvogel-dev avatar noblica avatar riywo avatar sebastiansson avatar srenault avatar thundercat1 avatar veloce avatar zlutfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gatsby-source-prismic-graphql's Issues

StaticQuery preview support

Hi and thanks again for all the work with this library!

Is it possible to enable preview on a StaticQuery somehow? I tried wrapping it in withPreview() manually but it didn't seem to work.

Thanks!

Error warning regarding persisting state function

Error appears in console on gatsby develop every 30 seconds or so and reads:

warning Error persisting state: function () {
    return (0, _utils.PrismicLink)({
      uri: "https://".concat(options.repositoryName, ".prism...<omitted>... } could not be cloned.

Versions in use:

  • gatsby-source-prismic-graphql - 3.1.3
  • gatsby - 2.3.34

Happy to provide any other information needed

Issue with page generation

Hi,

I'm having a very weird issue with this plugin.

On gatsby-config.js, I'm using the code below to generate pages :

pages: [{ // (optional)
          type: 'Post',         // TypeName from prismic
          match: '/blog/:uid',  // Pages will be generated under this pattern (optional)
          path: '/blog-preview',        // Placeholder page for unpublished documents
          component: require.resolve('./src/templates/post.js')
        }]

When trying to access the /blog/first-post page (for example), I'm not getting any data though I'm using this GraphQL query (which should work normally) :

query getPosts($uid: String!) {
  prismic {
    allPosts(uid: $uid) {
      edges {
        node {
          image
          title
          content
          _meta {
            type
            alternateLanguages {
              lang
              type
              id
              uid
            }
          }
        }
      }
    }
  }
}

As soon as I stop the gatsby process, change gatsby-config.js page generation to '/post/:uid', and do npm start, I still cannot access '/post/first-post' BUT can access '/blog/first-post' (the previous pathname I provided on the previous build). And anytime I change the path in page generation, the previous path is working and not the new one.

I'm not sure why it happens this way. I've tried removing the public folder so it rebuilds the whole folder from zero but it's still happening.

Does anyone have an idea of how to solve this?

Thanks a lot!

Error on build

First time looking at this source plugin, seem to be getting this error on build

 ERROR #11321  PLUGIN

"gatsby-source-prismic-graphql" threw an error while running the sourceNodes lifecycle:

The "options.agent" property must be one of type Agent-like Object, undefined, or false. Received type function

Steps to reproduce:

  • cd /examples/static-query
  • npm install
  • npm run develop

thanks!

Doesn't work with Gatsby 2.9.0

Just upgraded Gatsby to 2.9.0 and get the following error

error Plugin gatsby-source-prismic-graphql returned an error

TypeError: createPageDependency is not a function

  • gatsby-node.js:100 NamespaceUnderFieldTransform.resolver
    [greatstate]/[gatsby-source-graphql]/gatsby-node.js:100:7

Support for Prismic slices / Linked documents?

The query for getting slice content requires an inline fragment:
https://prismic.io/docs/graphql/query-the-api/retrieve-slice-content

which will throw:
index.js:2177 You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Apollo Client will not be able to accurately map fragments. To make this error go away, use the IntrospectionFragmentMatcher as described in the docs: https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher
WARNING: heuristic fragment matching going on!

I didn't test this (because all my links are inside slices :) ), but the linked documents also require inline fragments:
https://prismic.io/docs/graphql/query-the-api/retrieve-link-content

So I assume they would throw the same error?

Preview path interferes with static page

I have a news index page published under src/pages/news

Each article is published below this folder using this configuration:

    {
            type: 'News_article',
            match: '/news/:uid',
            path: '/news', // CONFLICT in static building
            component: require.resolve('./src/templates/article.js')
     },

This configuration works in dev mode, but the Preview route overrides the static page when building for production.

I guess this is because both the static page and the preview route wants to use /news.

I tried setting the preview route with a trailing slash /news/ instead which preserves the static page, BUT then the article UID is not resolved properly in Preview mode for some reason. When entering preview the route is resolved as: news/?uid=... and it displays the index page.

To work around this I created a separate preview config and modified the link resolver to pick the correct one when previewing:

   {
            type: 'News_article', // TypeName from prismic
            match: '/news/:uid', // Pages will be generated under this pattern
            path: '/news/', // Placeholder page for unpublished documents - NOT USED
            component: require.resolve('./src/templates/article.js')
          },
          // Map for unpublished New Articles
          {
            type: 'News_article', // TypeName from prismic
            match: '/preview-article/:uid', // Pages will be generated under this pattern
            path: '/preview-article', // Placeholder page for unpublished documents
            component: require.resolve('./src/templates/article.js')
          },
// link resolver
if (doc.type === 'news_article') {
    if (doc.href) {
      // Preview path
      pathname = `/preview-article/${doc.uid}`
    } else {
      // Normal path
      pathname = `/news/${doc.uid}`
    }
  }

Not sure if it's safe to detect preview using the href property on the doc?

If it is safe, it would have been great if I could do this instead:

    {
            type: 'News_article',
            match: '/news/:uid',
            path: '/preview-article', // uid is not correctly resolved here
            component: require.resolve('./src/templates/article.js')
     }

However the UID seems to be lost when doing that - the article data is empty when loading an article under /preview-article/my-article

Any ideas on how to improve this?

StaticQuery example mounts twice

Hi,

I wanted to share my findings on using this plugin with StaticQuery.

When using the example syntax the wrapped component will mount multiple times for some reason, I'm not exactly sure why. I solved it by using this syntax:

class StaticQueryWithPreview extends React.PureComponent {
  // Make sure updated props are passed correctly
  renderComponent = withPreview(data => {
    return <Layout {...this.props} prismic={data.prismic}/>
  }, query, fragments)

  render () {
    return (
      <StaticQuery
        query={query}
        render={this.renderComponent}
      />
    )
  }
}

Failed to fetch preview

Hi again!

Finally got access to GraphQL in Prismic, but didn't get too far...

With a super simple pages/index fetched based on the uid:

export const query = graphql`
    query {
        prismic {
            page(uid: "my-index", lang: "en-us") {
                title
            }
        }
    }
`;

I've setup the preview in url in prismic to "http://localhost:8000" & "/preview"

a )When I navigate to http://localhost:8000, I see the published title ("My index") and even the draft one ("My index (DRAFT EDIT)") in the preview thingie from prismic:

image

Is it supposed to show the page with preview content from the sidebar link? If so, it just reloads the same page when clicking the "draft preview".

b) When I navigate to the preview page from prismic's preview button, I can see it redirect to the preview/token=bla page correctly and then to http://localhost:8000, but there it throws:

image

"GraphQLError: Syntax Error: Unexpected Int "1826773283"
at syntaxError (http://localhost:8000/commons.js:23614:10)
at unexpected (http://localhost:8000/commons.js:28536:68)
at parseDefinition (http://localhost:8000/commons.js:27210:9)
at many (http://localhost:8000/commons.js:28566:16)
at parseDocument (http://localhost:8000/commons.js:27170:18)
at parse (http://localhost:8000/commons.js:27108:10)
at parseDocument (http://localhost:8000/commons.js:23107:16)
at gql (http://localhost:8000/commons.js:23148:10)
at getQuery (http://localhost:8000/commons.js:21864:36)
at getIsolatedQuery (http://localhost:8000/commons.js:21873:17)
at _class2._callee$ (http://localhost:8000/commons.js:22677:81)
at tryCatch (http://localhost:8000/commons.js:103443:40)
at Generator.invoke [as _invoke] (http://localhost:8000/commons.js:103669:22)
at Generator.prototype.(anonymous function) [as next] (http://localhost:8000/commons.js:103495:21)
at asyncGeneratorStep (http://localhost:8000/commons.js:3694:24)
at _next (http://localhost:8000/commons.js:3716:9)
at http://localhost:8000/commons.js:3723:7
at new Promise ()
at _class2. (http://localhost:8000/commons.js:3712:12)
at _class2.load (http://localhost:8000/commons.js:22714:25)
at _class2.componentDidMount (http://localhost:8000/commons.js:22727:20)
at _class2.componentDidMount (http://localhost:8000/commons.js:96247:123)
at commitLifeCycles (http://localhost:8000/commons.js:84990:22)
at commitAllLifeCycles (http://localhost:8000/commons.js:86355:7)
at HTMLUnknownElement.callCallback (http://localhost:8000/commons.js:68912:14)
at Object.invokeGuardedCallbackDev (http://localhost:8000/commons.js:68962:16)
at invokeGuardedCallback (http://localhost:8000/commons.js:69019:31)
at commitRoot (http://localhost:8000/commons.js:86551:7)
at completeRoot (http://localhost:8000/commons.js:88003:3)
at performWorkOnRoot (http://localhost:8000/commons.js:87932:9)
at performWork (http://localhost:8000/commons.js:87840:7)
at performSyncWork (http://localhost:8000/commons.js:87814:3)
at requestWork (http://localhost:8000/commons.js:87683:5)
at scheduleWork (http://localhost:8000/commons.js:87492:5)
at scheduleRootUpdate (http://localhost:8000/commons.js:88160:3)
at updateContainerAtExpirationTime (http://localhost:8000/commons.js:88188:10)
at updateContainer (http://localhost:8000/commons.js:88245:10)
at ReactRoot../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render (http://localhost:8000/commons.js:88537:3)
at http://localhost:8000/commons.js:88677:14
at unbatchedUpdates (http://localhost:8000/commons.js:88043:10)
at legacyRenderSubtreeIntoContainer (http://localhost:8000/commons.js:88673:5)
at render (http://localhost:8000/commons.js:88734:12)
at http://localhost:8000/commons.js:1039:7"

I didn't dig into it deeper yet, thought I'd ask first if I'm missing something obvious in my setup? If it's nothing obvious I can create a smaller reproduction and actually try to look into what's causing the error.

(I also tried setting the API to public, had no effect)

Suggestion for documentation update

Hi - we spent a good amount of time spelunking through the code because we couldn't get this to work - the prismic preview widget was loading but the updated content wasn't displaying on the page. Eventually realised it's because our graphql queries weren't called query.

In hindsight it's pretty clear from the example code, but especially as we were coming over from a site that was kicked off from a Gatsby starter where most of the examples tend to be called pageQuery it took a while to click. Might save someone else some time to call this out explicitly somewhere?

Thanks!

Pagination

Hello,

My prismic has 200 pages. I need to create them all on gatsby-node. How do you run the pagination on that page?

Pagination

Long time no see 👋

I'm using this plugin with the preview disabled, and was trying out the pagination. In your example prismic.load() gets passed as prop to the React Component, but the only prop that gets passed down for me is the graphql data in data.prismic.

I tried enabling the preview and even checking the props in the preview/ version, but it's not there... do I need to do some other undocumented magic to get access to the load function and does it work with the preview disabled?

Thanks again!

Preview not working with Prismic's private API

The preview functionality of this plugin is only working when the repository settings of Prismic are set to Open API. When you select either Private API or Public API for Master only the plugin is not working (due to missing auth tokens). Can we add support for this?

Uncaught TypeError: Cannot set property 'query' of undefined

I'm getting this JS error when running in production ie gatsby build && gatsby serve. (gatsby develop works fine.)

This issue seems to be fixed in this commit: f05a5e6

But since it hasn't been released and there is no issue I thought I'd add one to help other people with the same errors.

app-81af51e12fde343aa4e9.js:1 Uncaught TypeError: Cannot set property 'query' of undefined
    at Object.<anonymous> (app-81af51e12fde343aa4e9.js:1)
    at u (webpack-runtime-17c45135f10339e5f97e.js:1)
    at Object.<anonymous> (app-81af51e12fde343aa4e9.js:1)
    at u (webpack-runtime-17c45135f10339e5f97e.js:1)
    at Object.<anonymous> (app-81af51e12fde343aa4e9.js:1)
    at u (webpack-runtime-17c45135f10339e5f97e.js:1)
    at Module.<anonymous> (app-81af51e12fde343aa4e9.js:1)
    at u (webpack-runtime-17c45135f10339e5f97e.js:1)
    at r (webpack-runtime-17c45135f10339e5f97e.js:1)
    at Array.t [as push] (webpack-runtime-17c45135f10339e5f97e.js:1)

Builds broken due to JavaScript TypeError

I'm seeing an uncaught TypeError in the javascript console when running built Gatsby projects while using this plugin.

It does look like the error is in the gatsby-source-graphql-universal package (so maybe this issue belongs there?) but is originating from this package's WrapPage component.

Screen Shot 2019-07-18 at 9 06 57 AM

When spinning up the Gatsby development server everything works great, but when I run the build command, the built javascript is throwing the following error:

Uncaught TypeError: Cannot set property 'query' of undefined

In doing a little bit of digging with Chrome's debugger, it looks like the package is trying to set the query prop type on StaticQuery, which isn't working since StaticQuery isn't an object, it's a function:

Screen-Shot-2019-07-18-at-9 24 46-AM

(Again, this is technically in the gatsby-source-graphql-universal package, so I'm happy to port this issue over to that package).

I'm experiencing this issue on all built projects I'm working on, including the arnaud example project in this repo (the above screenshots are from a build from that example). That example is using:

  • gatsby version 2.13.27
  • gatsby-source-prismic-graphql version 3.3.0
  • gatsby-source-graphql-universal version 3.1.3 (as a dependency of gatsby-source-prismic-graphql).

I'm also working in Chrome version 75.0.3770.100.

Data not being returned during create pages and dependencies missing

Looks like I'm not getting any data back during the create pages phase of the build process.

gatsby-config.js:

{
  resolve: `gatsby-source-prismic-graphql`,
  options: {
    repositoryName: `ihavebeenreplaced`,
    accessToken: `${process.env.PRISMIC_ACCESS_TOKEN}`,
    path: '/preview',
    previews: true,
    refetchInterval: 60,
    pages: [
      {
        type: 'home_page',
        match: '/',
        path: '/',
        component: require.resolve('./src/templates/Home/Home.jsx'),
      },
      {
        type: 'contact_page',
        match: '/contact',
        path: '/contact',
        component: require.resolve('./src/templates/Contact/Contact.jsx'),
      },
      {
        type: 'blog_article',
        match: '/blog/:uid',
        path: '/blog',
        component: require.resolve('./src/templates/BlogArticle/BlogArticle.jsx'),
      },
      {
        type: 'case_study',
        match: '/work/:uid',
        path: '/work',
        component: require.resolve('./src/templates/CaseStudy/CaseStudy.jsx'),
      },
      {
        type: 'event',
        match: '/events/:uid',
        path: '/events',
        component: require.resolve('./src/templates/Event/Event.jsx'),
      },
      {
        type: 'job_listing',
        match: '/careers/:uid',
        path: '/careers',
        component: require.resolve('./src/templates/JobListing/JobListing.jsx'),
      },
    ],
  },
},

I've installed the gatsby-source-prismic-graphql to my dependences, package.json:

"dependencies": {
...
"gatsby-source-prismic-graphql": "^3.0.5",
...

The error I'm getting in the console reads:

error Plugin gatsby-source-prismic-graphql returned an error


  TypeError: Cannot read property 'prismic' of undefined
  
  - gatsby-node.js:91 _callee$
    [GreatState]/[gatsby-source-prismic-graphql]/gatsby-node.js:91:30
  
  - util.js:16 tryCatcher
    [GreatState]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [GreatState]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [GreatState]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:606 Promise._settlePromiseCtx
    [GreatState]/[bluebird]/js/release/promise.js:606:10
  
  - async.js:142 _drainQueueStep
    [GreatState]/[bluebird]/js/release/async.js:142:12
  
  - async.js:131 _drainQueue
    [GreatState]/[bluebird]/js/release/async.js:131:9
  
  - async.js:147 Async._drainQueues
    [GreatState]/[bluebird]/js/release/async.js:147:5
  
  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [GreatState]/[bluebird]/js/release/async.js:17:14

I also get a warning that the gatsby-source-prismic-graphql plugin is missing dependencies in it's /utils directory:

 ERROR  Failed to compile with 2 errors                                                                                                                                                                                                        11:57:34 AM

These dependencies were not found:

* apollo-boost in ./node_modules/gatsby-source-prismic-graphql/utils/getApolloClient.js
* apollo-cache-inmemory in ./node_modules/gatsby-source-prismic-graphql/utils/getApolloClient.js

To install them, you can run: npm install --save apollo-boost apollo-cache-inmemory
✖ 「wdm」: 
ERROR in ./node_modules/gatsby-source-prismic-graphql/utils/getApolloClient.js
Module not found: Error: Can't resolve 'apollo-boost' in '/Users/jonjames/Sites/GreatState/node_modules/gatsby-source-prismic-graphql/utils'
 @ ./node_modules/gatsby-source-prismic-graphql/utils/getApolloClient.js 14:19-42
 @ ./node_modules/gatsby-source-prismic-graphql/components/WrapPage.js
 @ ./node_modules/gatsby-source-prismic-graphql/gatsby-browser.js
 @ ./.cache/api-runner-browser-plugins.js
 @ ./.cache/api-runner-browser.js
 @ ./.cache/app.js
 @ multi event-source-polyfill (webpack)-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false ./.cache/app

ERROR in ./node_modules/gatsby-source-prismic-graphql/utils/getApolloClient.js
Module not found: Error: Can't resolve 'apollo-cache-inmemory' in '/Users/jonjames/Sites/GreatState/node_modules/gatsby-source-prismic-graphql/utils'
 @ ./node_modules/gatsby-source-prismic-graphql/utils/getApolloClient.js 16:27-59
 @ ./node_modules/gatsby-source-prismic-graphql/components/WrapPage.js
 @ ./node_modules/gatsby-source-prismic-graphql/gatsby-browser.js
 @ ./.cache/api-runner-browser-plugins.js
 @ ./.cache/api-runner-browser.js
 @ ./.cache/app.js
 @ multi event-source-polyfill (webpack)-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false ./.cache/app
ℹ 「wdm」: Failed to compile.
error Plugin gatsby-source-prismic-graphql returned an error

If I can provide any more information to help, please let me know.

fragment preview support

Is there a recommended way of defining GraphQL fragments so that the Apollo client knows about them?

Currently when I defined a fragment in a component like this:

export const query = graphql`
  fragment SiteSettings on PRISMIC_Site_settings {
    ...
  }
`

The preview throws this error:

index.js:2177 Failed to fetch preview Error: Network error: Response not successful: Received status code 500
    at new ApolloError (bundle.esm.js:60)

Response:

{"message":"Query does not pass validation. Violations:\n\nUnknown fragment 'SiteSettings'. (line 30, column 5):\n    ...SiteSettings\n    ^"}

So it seems as if the fragment is unknown at this point.


Sorry for the storm of new issues. We really hope to use this plugin on a project to enable the preview functionality. I'm reporting what I find and hope it helps someone in the future :)

Updating from 2.2.0 -> 3.0.2

Hey again,

I tried updating to the latest version, but gatsby develop throws:

error Plugin gatsby-source-prismic-graphql returned an error

SyntaxError: Unexpected token, expected "," (206:39)

  • index.js:3831 Object.raise
    [Website]/[@babel]/parser/lib/index.js:3831:17

  • index.js:5143 Object.unexpected
    [Website]/[@babel]/parser/lib/index.js:5143:16

  • index.js:5135 Object.expect
    [Website]/[@babel]/parser/lib/index.js:5135:28

  • index.js:6419 Object.parseParenAndDistinguishExpression
    [Website]/[@babel]/parser/lib/index.js:6419:14

  • index.js:2670 Object.parseParenAndDistinguishExpression
    [Website]/[@babel]/parser/lib/index.js:2670:18

  • index.js:6215 Object.parseExprAtom
    [Website]/[@babel]/parser/lib/index.js:6215:21

  • index.js:3552 Object.parseExprAtom
    [Website]/[@babel]/parser/lib/index.js:3552:20

  • index.js:5862 Object.parseExprSubscripts
    [Website]/[@babel]/parser/lib/index.js:5862:23

  • index.js:5842 Object.parseMaybeUnary
    [Website]/[@babel]/parser/lib/index.js:5842:21

  • index.js:5802 Object.parseExprOpBaseRightExpr
    [Website]/[@babel]/parser/lib/index.js:5802:34

  • index.js:5795 Object.parseExprOpRightExpr
    [Website]/[@babel]/parser/lib/index.js:5795:21

  • index.js:5774 Object.parseExprOp
    [Website]/[@babel]/parser/lib/index.js:5774:27

  • index.js:5739 Object.parseExprOps
    [Website]/[@babel]/parser/lib/index.js:5739:17

  • index.js:5702 Object.parseMaybeConditional
    [Website]/[@babel]/parser/lib/index.js:5702:23

  • index.js:5647 Object.parseMaybeAssign
    [Website]/[@babel]/parser/lib/index.js:5647:21

  • index.js:2621 Object.parseMaybeAssign
    [Website]/[@babel]/parser/lib/index.js:2621:18

Do you have any advice on how to debug this further? Same error with both the latest gatsby version and 2.1.37

Changes in Prismic data structures don't populate?

Hello! Thank you for this great plugin. I am relatively new to GraphQL, Gatsby and Prismic, but excited about what I'm learning.

One issue I've encountered is that when I am developing in Gatsby using this plugin and I change my types or data structure in Prismic, I am not able to immediately use the new properties or types in Gatsby. It seems the GraphQL schema does not sync? Or perhaps its on the Prismic side?

I appreciate any clarification you can provide!

Best,
Phil

[Question] Custom match variable

Sorry if this is in the docs. I tried to look for it but couldn't find it.

I have a custom type, that is Article, but want to publish the route under different Authors.

{
  pages: [{
    type: 'Article',
    match: '/article/:author/:uid',
    path: '/article',
    component: require.resolve('./src/templates/article.js'),
  }],
}

Example generated urls

/article/christian/foo-bar
/article/christian/hello-world
/article/sakai/leet
/article/sakai/uber-hacker

Is this possible?

Support of template ?

Hello,

I dont use pages but only templates.

Do you think it is possible to use it?

Preview not working with multi language

I'm unable to access the preview functionality for any of the languages.
I have set up the project similarly to the languages example.
My gatsby config:

{
  resolve: 'gatsby-source-prismic-graphql',
  options: {
    repositoryName: 'scenarex', 
    accessToken : `${process.env.API_KEY}`,
    defaultLang: 'en-ca', 
    langs: ['en-ca', 'fr-ca'],
    path: '/preview', 
    previews: true, 
    pages: [{ 
      type: 'Member',
      match: '/:lang/:uid', 
      path: '/member', 
      component: require.resolve('./src/templates/member.js'),
    },
    { 
      type: 'Home', 
      match: '/:lang', 
      path: '/home', 
      component: require.resolve('./src/templates/home.js'),
    },
  ],
  }
}

This is my home template:

import React from "react"
import { graphql, Link } from "gatsby";
import Layout from "../components/layout"
import { RichText } from 'prismic-reactjs'
import { linkResolver } from "../prismic/linkResolver";


const IndexPage = ({ data }) => {
  console.log(data);
  const doc = data.prismic.allHomes.edges.slice(0,1).pop();
  if(!doc) return null;
  let page = doc.node;
  let tools;
  let partners;
  for (let i=0; i<page.body.length; i++) {
    if (page.body[i].__typename === "PRISMIC_HomeBodyPartners") {
      partners = page.body[i]
    }
    else {
      tools = page.body[i]
    }
  }
  return (
  <Layout title={page.title[0].text} path="/">
    <main>
      <section className="masthead">
        {RichText.render(page.text)}
      </section>
      <section className="masthead upper-border">
        <div className="big">{RichText.render(page.partnerstitle)}</div>
        {partners.fields.length > 0 &&
        <div className="row flex-item ml-4 mb-4">
          {(partners.fields).map((partner,i) =>
            <div className="flex-item pl-2 p-0" key={i}>
              <a href={partner ? partner.link.url : ""}>
                <img className="grey" src={partner.img.url} style={{maxHeight: "60px"}} alt=""/>
              </a>
            </div>
          )}
        </div>
        }
      </section>
      <section className="masthead upper-border">
        <div className="big">{RichText.render(page.toolstitle)}</div>
        {tools.fields.length > 0 &&
        <div className="row flex-item">
          {(tools.fields).map((tool,i) =>
            <div className="md:w-3/12 w-full ml-0 pl-6 block md:flex-item" key={i}>
              <span className="fa-layers fa-fw fa-8x">
                <i className="fa fa-circle icon-background"></i>
                <i className={tool.icon[0].text} data-fa-transform="shrink-6"></i>
              </span>
              <h2><a href={tool.link.url}>{RichText.render(tool.name)}</a></h2>
              {RichText.render(tool.text1)}
            </div>
            )}
        </div>
        }
      </section>
    </main>
  </Layout>
  )
}

export const homeQuery = graphql`
query homeQuery($id: String) {
prismic {
  allHomes(id: $id) {
    edges {
      node {
        title
        _meta {
          uid
          id
          lang
          }
        text
        partnerstitle
        toolstitle
        body {
          __typename
          ... on PRISMIC_HomeBodyTools {
            fields {
              name
              icon
              text1
              link {
              ... on PRISMIC__ExternalLink{
                    url
                  }
              }
            }
          }
          ... on PRISMIC_HomeBodyPartners{
            fields {
              link {
                ... on PRISMIC__ExternalLink{
                      url
                    }
              }
              img
            }
          }
        }
        }
      }
    }
  }
}
`
IndexPage.query = homeQuery;
export default IndexPage

and my member template:

import React from "react";
import { graphql } from "gatsby";
import Layout from "../components/layout";
import { RichText } from 'prismic-reactjs';

export const MemberTemplate = props => {
  return (
    <div className="row">
     <div className="row">
       <div className="md:w-6/12 w-full px-12">
         <img src={props.page.img.url} alt=""/>
         <a href={`mailto:${props.page.email[0].text}`}><i className="fas fa-envelope"></i> {props.page.email[0].text}</a>
       </div>
       <div className="md:w-6/12 w-full px-12 mt-0">
         <div className="big">{RichText.render(props.page.name)}</div>
         {RichText.render(props.page.description)}
       </div>
     </div>
   </div>
  )
}

const MemberPage = ({ data }) => {
  console.log(data)
  const doc = data.prismic.allMembers.edges.slice(0,1).pop();
  if(!doc) return null;
  return (
    <Layout title={doc.node.name.text} path="/" >
      <MemberTemplate page={doc.node} />
    </Layout>
  );

};

export const peopleQuery = graphql`
query peopleQuery($id: String) {
prismic {
  allMembers(id: $id) {
    edges {
      node {
        name
        description
        img
        email
        _meta {
          uid
          id
          lang
          }
        }
      }
    }
  }
}
MemberPage.query = peopleQuery;
export default MemberPage

I am using Gatsbyv2.12.2 and gatsby-source-prismic-graphqlv3.4.0-beta.0.
When trying to access the preview from the prismic dashboard I receive this error in the gatsby-browser:
Screen Shot 2019-07-26 at 11 02 59 AM

out of alpha

I noticed the version has bumped up to 3.2.0 without the 'alpha' tag. Does this means it's out of alpha?

Comments in GraphQL queries break Previews

With a simple template query:

export const query = graphql`
    query PageByUid($uid: String!) {
        prismic {
            page(uid: $uid, lang: "en-us") {
                title
                #ingress <--- without the comment this works
            }
        }
    }
`;

the preview functionality breaks if # comments are inserted with the following error in the browser:

GraphQLError
locations: [{…}]
message: "Syntax Error: Expected Name, found "
extensions: undefined
nodes: undefined
originalError: undefined
path: undefined
positions: [98]
source: Source
body: " query PageByUid($uid: String!) { prismic { page(uid: $uid, lang: "en-us") { title #ingress } } } "
locationOffset: {line: 1, column: 1}
name: "GraphQL request"
Symbol(Symbol.toStringTag): (...)
proto: Object
stack: "GraphQLError: Syntax Error: Expected Name, found ↵ at syntaxError (http://localhost:8008/commons.js:24626:10)↵ at expectToken (http://localhost:8008/commons.js:29636:67)↵ at parseName (http://localhost:8008/commons.js:28303:15)↵ at parseField (http://localhost:8008/commons.js:28518:21)↵ at parseSelection (http://localhost:8008/commons.js:28507:104)↵ at many (http://localhost:8008/commons.js:29727:16)↵ at parseSelectionSet (http://localhost:8008/commons.js:28494:17)↵ at parseField (http://localhost:8008/commons.js:28535:91)↵ at parseSelection (http://localhost:8008/commons.js:28507:104)↵ at many (http://localhost:8008/commons.js:29724:16)↵ at parseSelectionSet (http://localhost:8008/commons.js:28494:17)↵ at parseField (http://localhost:8008/commons.js:28535:91)↵ at parseSelection (http://localhost:8008/commons.js:28507:104)↵ at many (http://localhost:8008/commons.js:29724:16)↵ at parseSelectionSet (http://localhost:8008/commons.js:28494:17)↵ at parseOperationDefinition (http://localhost:8008/commons.js:28422:19)↵ at parseExecutableDefinition (http://localhost:8008/commons.js:28375:16)↵ at parseDefinition (http://localhost:8008/commons.js:28339:16)↵ at many (http://localhost:8008/commons.js:29724:16)↵ at parseDocument (http://localhost:8008/commons.js:28320:18)↵ at parse (http://localhost:8008/commons.js:28258:10)↵ at parseDocument (http://localhost:8008/commons.js:24112:16)↵ at gql (http://localhost:8008/commons.js:24153:10)↵ at getQuery (http://localhost:8008/commons.js:21476:36)↵ at getIsolatedQuery (http://localhost:8008/commons.js:21485:15)↵ at http://localhost:8008/commons.js:22327:69"
proto: Error

Better Link Resolver Example

Hello, I just wanted to share this LinkResolver helper that I made because the current RichText in prismic-reactjs doesn't seem to work with the LinkResolver in this README - I've tried adding the snippet in gatsby-browser.js and could not get it to work. I then found out that I can use the RichText with serializeHyperlink from prismic-reactjs to conditionally render a Gatsby Link or a regular link if it's to an external URL. I think it would be great to either provide this example (or better one) on the README or somehow bake this into the library because it seems like something that should "just work", since Prismic gives you clear distinction between local document links and external links, it shouldn't require everyone to write custom code to render these embedded links in RichText.

import { Link } from "gatsby"
import { RichText } from "prismic-reactjs"
import React from "react"

export function LinkResolver(type, element, content, children, index) {
  if (element.data.link_type === "Web") {
    return <a href={element.data.url}>{content}</a>
  }
  return (
    <Link key={element.data.id} to={element.data.uid}>
      {content}
    </Link>
  )
}

// Usage
function PageContent({doc}) { 
    return <RichText render={doc} serializeHyperlink={LinkResolver} />
}

Variables in GraphQL queries?

Hæ!

So, I'm using templates with graphQL variables in the queries, like in this starter example:
https://github.com/LekoArts/gatsby-starter-prismic/blob/master/src/templates/post.jsx

The query I'm making in the page.tsx template looks like this:

export const query = graphql`
    query PageByUid($uid: String!) {
        prismic {
            page(uid: $uid, lang: "en-us") {
                title
            }
        }
    }
`;

And that works for the published content, but the preview query fails, because it doesn't add the variables:
image

Testing the same query with "query variables" { "uid": "my-first-page" } in the Prismic GraphiQL (https://my-repo.prismic.io/graphql) adds them correctly:

image

a) Am I missing something or is this not supported?
b) If it's not supported: Do you use something else to setup dynamic pages? If there's no workaround, it's a big blocker for me :(
b) If there's no workaround: Is it a big thing to add? Could I help?
c) If it's possible to add: How many other features are missing compared to gatsby-source-prismic? I'm just getting started with gatsby and graphQL, so I don't even know what features I will need, but this project I'm setting up is quite large, so probably a lot of them, whatever they are?

Thanks!

3.0.0-alpha.14 Preview not updating page content

I can't get the Preview to update the page content using 3.0.0-alpha.14

This is a static page where the Prismic toolbar shows the preview content but not the page:

https://www.dropbox.com/s/75ha7wo2h4803m8/Screenshot%202019-03-20%2011.00.45.png?dl=0

Same for dynamically created pages using the pages: property, it's not updating the content.

You can see the Prismic toolbar has the updated title, but not the page content:
https://www.dropbox.com/s/3q8m3jrdo62yley/Screenshot%202019-03-20%2010.26.41.png?dl=0

GraphQL api conflict?

I am already using the gatsby-source-graphql plugin with Shopify. It seems to have an issue with the page creation conflict, but I'm already a little lost trying to understand the root of the problem.

Enabling gatsby-source-graphql results in the error below. Disabling it completes the build just fine.

error Plugin gatsby-source-graphql returned an error


  Error: The plugin "gatsby-source-graphql" created a node of a type owned by another plugin.
          The node type "GraphQLSource" is owned by "gatsby-source-prismic-graphql".
          If you copy and pasted code from elsewhere, you'll need to pick a new type name
          for your new node(s).
          The node object passed to "createNode":
          {
      "id": "70a87664-0538-5739-87f6-ec3b13239436",
      "typeName": "Shopify",
      "fieldName": "shopify",
      "parent": null,
      "children": [],
      "internal": {
          "type": "GraphQLSource",
          "contentDigest": "2b604d8d767435561bfb1249116b468d",
          "ignoreType": true,
          "owner": "gatsby-source-graphql"
      }
  }
          The plugin creating the node:
          {
      "resolve": "/Users/olliejt/Documents/GitHub/VBI/gatsby-starter-shopifypwa/node_modules/gatsby-source-graphql",
      "id": "b9f70474-1178-5378-9955-dbbd3d4b9314",
      "name": "gatsby-source-graphql",
      "version": "2.0.18",
      "pluginOptions": {
          "plugins": [],
          "typeName": "Shopify",
          "fieldName": "shopify",
          "url": "https://visuals-by-impulse.myshopify.com/api/graphql",
          "headers": {
              "X-Shopify-Storefront-Access-Token": "REMOVED-TOKEN"
          }
      },
      "nodeAPIs": [
          "sourceNodes"
      ],
      "browserAPIs": [],
      "ssrAPIs": [],
      "pluginFilepath": "/Users/olliejt/Documents/GitHub/VBI/gatsby-starter-shopifypwa/node_modules/gatsby-source-graphql"
  }

  - actions.js:542 actions.createNode
    [gatsby-starter-shopifypwa]/[gatsby]/dist/redux/actions.js:542:148

  - redux.js:468
    [gatsby-starter-shopifypwa]/[redux]/lib/redux.js:468:35

  - api-runner-node.js:63 doubleBoundActionCreators.(anonymous function).args
    [gatsby-starter-shopifypwa]/[gatsby]/dist/utils/api-runner-node.js:63:13

  - gatsby-node.js:97 Object.<anonymous>
    [gatsby-starter-shopifypwa]/[gatsby-source-graphql]/gatsby-node.js:97:5

  - Generator.next


warning The gatsby-source-graphql plugin has generated no Gatsby nodes. Do you need it?

Previews failing with 500 error

Hello, Previews have been working great with this plugin, but now they are no longer working for our team. I get a 500 error on the fetch to get the preview, a notice that it has been blocked by CORS policy. We haven't updated anything recently, and it has been working fine with Gatsby and Prismic. Any ideas?

GET ... 500 (Internal Server Error)

Access to fetch at 'https://xxxx.prismic.io/graphql?query=...from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Error: Network error: Failed to fetch
    at new ApolloError

yarn install fails on v2.3

Hæ,

I noticed that yarn add gatsby-source-prismic-graphql results in the following error for some reason:

error An unexpected error occurred: "could not find a copy of gatsby to link

npm install seems to work fine though. Any ideas?

Cheers

TypeError: createContentDigest is not a function

Moi,

So I've had preview: false until now, when I tried to enable it now I get this error with gatsby develop at the refetchInterval:

success extract queries from components — 0.189 s
error UNHANDLED EXCEPTION

TypeError: createContentDigest is not a function

  • gatsby-node.js:146 createSchemaNode
    [Website]/[gatsby-source-graphql]/gatsby-node.js:146:29

  • gatsby-node.js:121 Timeout.refetcher [as _onTimeout]

The first build works fine, it's only whatever refetchInterval triggers that doesn't.

I can try to find the time later to dig deeper into the error and/or create a reproduction, but any pointers where to look are welcome. I've tried with both gatsby v2.1.37 and the newest.

Can't launch preview from Prismic dashboard

I've been unable to get content in my previews when launched from the Prismic dashboard.

This is my gatsby-config.js

{
      resolve: 'gatsby-source-prismic-graphql',
      options: {
        repositoryName: 'cartolab',
        accessToken: `${process.env.PRISMIC_API_TOKEN}`,
        path: '/preview',
        previews: true,
        pages: [
          {
            type: 'Blog_post',
            match: '/blog/:uid',
            path: '/blog-preview',
            component: require.resolve('./src/templates/blog-post.js'),
          },
        ],
      },
    },

This is my blog-post template, modeled after the pagination example:

import React from 'react';
import { Container, Header, Image, Responsive } from 'semantic-ui-react';
import { graphql } from 'gatsby';
import { withLayout } from '../layouts/Layout';
import SharingButtons from '../components/SharingButtons';
import { RichText } from 'prismic-reactjs';
import { get } from 'lodash';

export const query = graphql`
  query BlogPostByUIDQuery($uid: String!) {
    prismic {
      blog_post(uid: $uid, lang: "en-us") {
        _meta {
          uid
          type
          tags
          lastPublicationDate
        }
        post_title
        post_author
        thumbnail
        post_body
      }
    }
  }
`;

const BlogPostTemplate = ({ data, location }) => {
  const title = get(data, 'prismic.blog_post.post_title[0].text', []);
  const author = get(data, 'prismic.blog_post.post_author', []);
  const publishDate = get(
    data,
    'prismic.blog_post._meta.lastPublicationDate',
    []
  );
  const postImage = get(data, 'prismic.blog_post.thumbnail.url', []);
  const postBody = get(data, 'prismic.blog_post.post_body', []);

  return (
    <div style={{ marginTop: '7em', marginBottom: '5em' }}>
      <Container text>
        <Header as="h1">{title}</Header>
        <p>by: {author}</p>
        <p>
          <i>{publishDate}</i>
        </p>
        <Responsive maxWidth={767}>
          <SharingButtons url={location.href} text={title} mobile />
        </Responsive>
        <Responsive minWidth={768}>
          <SharingButtons url={location.href} text={title} />
        </Responsive>

        <Image src={postImage} style={{ marginTop: '1em' }} />
        <div className="blog-post-body" style={{ marginTop: '1em' }}>
          <RichText render={postBody} />
        </div>
      </Container>
    </div>
  );
};

export default withLayout(BlogPostTemplate);

When I launch the Preview by clicking the button in Prismic, I see this:
image
The page loads, but the unpublished content doesn't.

If I then manually change the preview URL to be structured like .../blog-preview?uid=post-uid, then I see the content:
image

So, previews are sort of working, but not directly from the dashboard. Is there something obvious I'm missing to make sure they launch correctly from the Prismic dashboard?

Edit: Gatsby v2.4.3, plugin v 3.2

build not working

I have an issue using the prismic plugin. Everything works fine in develop mode. Data is coming back and preview seems to work fine. However if i build it looks like the data isn;'t available at build time?

error Building static HTML failed for path "/events"

See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html

8 | return (
9 | <>
> 10 | <SEO title={Event: ${data.event_title[0].text}} />
| ^
11 | <h1>{data.event_title[0].text}</h1>
12 | <p>{Event date: ${data.event_date}}</p>
'13 | <p>{Location: ${data.location[0].text}}</p>

WebpackError: TypeError: Cannot read property 'event_title' of null'

Component looks like this
const Event = ({ data: { prismic } }) => {
const data = prismic.event
return (
<>
<SEO title={Event: ${data.event_title[0].text}} />
h1>{data.event_title[0].text}</h1>
<p>{Event date: ${data.event_date}}</p>
<p>{Location: ${data.location[0].text}}</p>
<Link to="/events">Back to Events</Link>
</>
)
}

Event.query = query'

using
"gatsby": "2.3.16", "gatsby-source-prismic-graphql": "^3.1.3",

I'm console logging the data in the component and it looks fine in the build process but fails when it gets the component bit <SEO title={Event: ${data.event_title[0].text}} />. This is happening for lots of components

load() pagination returns old data on last page

Hey,

I was just testing out pagination/filtering using the provided load() function and noticed what I think is a bug:

When reaching the last page, the result will contain old data merged with the last page if the last page result is less than the pageSize. I'm seeing data from lastPage-1 merged with the single item from the last page.

I think it's because of this line? https://github.com/birkir/gatsby-source-prismic-graphql/blob/master/src/withPreview.tsx#L108

Is there any way we could get it to only return the new items on the last page?

This also becomes a problem when trying to filter the results.

UID param not passed into the template page query?

Hi! I'm facing issues when configuring the plugin to generate pages with templates. All seems to work except that the uid variable is not present in the page query, resulting in an empty edges array. Here's the gatsby-config plugin section:

  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-typescript`,
    {
      resolve: 'gatsby-source-prismic-graphql',
      options: {
        repositoryName: 'foobar',
        accessToken:
          'bazquux',
        lang: '*',
        pages: [{
          type: "Seo_page",
          match: "/pages/:uid",
          path: "/page",
          component: require.resolve("./src/templates/seo-page.tsx")
        }]
      },
    },
  ],

The data returned:

 "data": {
  "prismic": {
   "allSeo_pages": {
    "edges": []
   }
  }

However, when I do a similar thing via gatsby-node, everything works without a hitch:

  const { createPage } = actions;

  const prismicSeoPages = await graphql(`
          {
            prismic {
              allSeo_pages {
                edges {
                  node {
                    _meta {
                      uid
                    }
                  }
                }
              }
            }
          }
        `)


  prismicSeoPages.data.prismic.allSeo_pages.edges.forEach((edge: any) => {
    const node: any = edge.node;
    createPage({
      path: `/pages/${node._meta.uid}`,
      component: path.resolve(`./src/templates/seo-page.tsx`),
      context: {
        // Data passed to context is available
        // in page queries as GraphQL variables.
        uid: node._meta.uid,
      },
    });
  });

Any ideas on what the problem might be?

EDIT Here's the template page query:

export const query = graphql`
  query SeoPageQuery($uid: String) {
    prismic {
      allSeo_pages(uid: $uid) {
        edges {
          node {
            admin_page_title
            navigationStyle
            footerStyle
            content: content {
              __typename
            }
          }
        }
      }
    }
  }
`;

EDIT 2 package versions

    "gatsby": "^2.0.19",
     //   version "2.10.0"
    "gatsby-source-prismic-graphql": "^3.2.0",
     //   version "3.2.0"

Preview mode not working with Gatsby's wrapPageElement

If I use Gatsby's wrapPageElement, or a plugin that does, like @TylerBarnes gatsby-plugin-transition-link to create a persistent template layout, the Prismic preview mode feature stops working.

When I click the "Preview" button from the CMS with a persistent template setup on my Gatsby site (with wrapPageElement), I get the following:

image

Disabling the gatsby-plugin-transition-link plugin, or removing the use of wrapPageElement in my own gatsby-browser.js file (as the case may be) restores the preview functionality.


gatsby - ^2.3.16
gatsby-source-prismic-graphql - ^3.1.3


EDIT: typos

gatsby-plugin-sharp support?

A quick question while waiting for graphql support in my repo... do you plan on adding gatsby-plugin-sharp support or is there some hurdle that prevents it? Or could you give some pointers on how to add it?

Match pages for locales?

Hello,

I see we have

   pages: [{ // (optional)
      type: 'Article',         // TypeName from prismic
      match: '/article/:uid',  // Pages will be generated under this pattern
      path: '/article',        // Placeholder page for unpublished documents
      component: require.resolve('./src/templates/article.js'),
    }],

Which will allow you to say Article = /article/slug/ however is there a way to say

Article EN = /article/slug
Article FR = /articleinfrench/slug

etc?

gatsby-source-prismic-graphql, causing a build error on NOW and Netlify

`1:48:57 PM: success Build manifest and related icons — 0.291

1:48:57 PM: success onPostBootstrap — 0.305

1:48:57 PM: info bootstrap finished - 5.389 s

1:48:57 PM: success run static queries — 0.350 — 3/3 8.95 queries/second

1:48:58 PM: success Generating image thumbnails — 6/6 - 0.851 s

1:48:58 PM: error #98123 WEBPACK

1:48:58 PM: Generating JavaScript bundles failed

1:48:58 PM: Cannot read property 'options' of undefined

1:48:58 PM: File: .cache/production-app.js

1:48:58 PM: See our docs page for more info on this error: https://gatsby.dev/issue-how-to

1:48:58 PM: npm

1:48:58 PM: ERR! code ELIFECYCLE`

This error is thrown whenever I tried to integrate the CD/CI of both NOW and Netlify.
I know that the plugin is causing the error because whenever I remove it from the gatsby-config.js it all goes trough.

Here is a repo where this error can be reproduced:
https://github.com/solabels/solabels

414 (Request-URI Too Large)

Just ran into this problem with a longer page query. It seems the GraphQL GET request has a limitation on the query length in Prismic.

Could we send the query using POST instead? I noticed the Gatbsy graphql tool uses that to send the query and the same query works fine there.

My query as a reference below.

curl 'https://antlerco.prismic.io/graphql?query=query%20TeamPageQuery(%24filter%3A%20Boolean!%20%3D%20false%2C%20%24industryFilter%3A%20String%2C%20%24first%3A%20Int%20%3D%201%2C%20%24afterAdvisor%3A%20String)%20%7B%0A%20%20team_page(uid%3A%20%22team-page%22%2C%20lang%3A%20%22en-us%22)%20%7B%0A%20%20%20%20hero_title%0A%20%20%20%20introduction%0A%20%20%20%20body%20%7B%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20...%20on%20Team_pageBodyAll_team_members%20%7B%0A%20%20%20%20%20%20%20%20type%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20...%20on%20Team_pageBodyAdvisor_list%20%7B%0A%20%20%20%20%20%20%20%20type%0A%20%20%20%20%20%20%20%20fields%20%7B%0A%20%20%20%20%20%20%20%20%20%20featured_advisor%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...%20on%20Advisor%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20company%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20headshot%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20industry%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...%20on%20Industry_tag%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20uid%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20...%20on%20Team_pageBodyAdvisor_testimonials%20%7B%0A%20%20%20%20%20%20%20%20type%0A%20%20%20%20%20%20%20%20fields%20%7B%0A%20%20%20%20%20%20%20%20%20%20advisor%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...%20on%20Advisor%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20company%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20headshot%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20industry%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...%20on%20Industry_tag%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20uid%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20advisor_image%0A%20%20%20%20%20%20%20%20%20%20testimonial_text%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%20%20allLocations%20%7B%0A%20%20%20%20totalCount%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20startCursor%0A%20%20%20%20%20%20endCursor%0A%20%20%20%20%20%20hasPreviousPage%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20uid%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20body%20%7B%0A%20%20%20%20%20%20%20%20%20%20...%20on%20LocationBodyTeam_grid%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20fields%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20team_member%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...%20on%20Team_member%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20headshot%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%20%20allIndustry_tags%20%7B%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%20%20allAdvisors(first%3A%20%24first%2C%20after%3A%20%24afterAdvisor)%20%40skip(if%3A%20%24filter)%20%7B%0A%20%20%20%20totalCount%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20startCursor%0A%20%20%20%20%20%20endCursor%0A%20%20%20%20%20%20hasPreviousPage%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20industry%20%7B%0A%20%20%20%20%20%20%20%20%20%20...%20on%20Industry_tag%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%20%20filteredAdvisors%3A%20allAdvisors(first%3A%20%24first%2C%20after%3A%20%24afterAdvisor%2C%20where%3A%20%7Bindustry%3A%20%24industryFilter%7D)%20%40include(if%3A%20%24filter)%20%7B%0A%20%20%20%20totalCount%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20startCursor%0A%20%20%20%20%20%20endCursor%0A%20%20%20%20%20%20hasPreviousPage%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%7D%0A&operationName=TeamPageQuery&variables=%7B%22filter%22%3Afalse%2C%22first%22%3A2%2C%22afterAdvisor%22%3A%22YXJyYXljb25uZWN0aW9uOjA%3D%22%7D' -X OPTIONS -H 'Access-Control-Request-Method: GET' -H 'Origin: http://localhost:8000' -H 'Referer: http://localhost:8000/team' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' -H 'Access-Control-Request-Headers: content-type,prismic-ref' --compressed

Lots of whitespace in there but, even if that could be stripped out, it doesn't feel good to have to worry about query lengths.

I guess Fragments support #10 would help reduce the size, but that is also not fixing the real problem.

IE11 not supported when running gatsby develop

No need to fix this, but just in case anyone else tries to test their page in IE11 with gatsby develop and gets a heart attack when the page doesn't render at all throwing the following error (this is with examples/pagination):

image
(Syntax error, File: commons.js, Line: 15673, Column: 26)

Fear not, it does work with gatsby serve.

Gatsby develop works with angeloashmore/gatsby-source-prismic.

Also, great work with all the improvements, need to test them out soon :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.