The gatsby-source-prismic-graphql allowed you to dynamically fetch data by applying values to the variables defined in your page query. This was done using using 'prismic.load'. How can this be done using the recommended gatsby-source-prismic plugin?
Here is the example from the gatsby-source-prismic-graphql documentation:
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>
);
}