What API should I use to access Redux store through graphql query and update the store back
See original GitHub issueI’m querying Google Analytics and creating a node with data from it like this:
exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => {
const data = analytics().then((data) => {
const node = {
hits: data,
internal: {
type: "AnalyticsNode",
}
...
};
createNode(node);
});
};
then I need to transform this data using information from other nodes, say posts, so I can query these nodes and transform the data inside createPages
:
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions;
const result = await graphql(`
{
allPost() { ... }
analyticsNode() { ... }
}
`);
const resultingData = mixData();
and now I need to send this resultingData
back to the store to make it queryable inside pages. How do I do that?
If the page is static, I could send it through context
inside create pages:
createPage({
path: 'analytics',
component: path.resolve(`./src/templates/analytics.js`),
context: {
resultingData
}
});
but this wouldn’t work for for dynamic pages, i.e. /app
pages rendered using a Router.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Redux to Apollo: Data Access Patterns - Apollo GraphQL Blog
Redux isn't a very complicated library, it essentially boils down to a single object {} that stores all of your application's state and...
Read more >Querying your Redux store with GraphQL - madewithlove
We often already use GraphQL so is there a way we can use it to ... This is a detailed guide about how...
Read more >GraphQL for the React Redux Developer - Cresta
GraphQL is a popular API query language for clients to access data on servers. Cresta uses GraphQL in different ways to act as...
Read more >How to update the Redux store after Apollo GraphQL query ...
I would listen to changes in componentDidUpdate and when they happened dispatch an action that will set selectedItem in Redux store
Read more >Redux Essentials, Part 7: RTK Query Basics
Endpoints can be queries, which return data for caching, or mutations, which send an update to the server. The endpoints are defined using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@maxkoretskyi OK, now I understand a bit better what you’re after. A custom resolver is what you need. Attach as a new field on
Analytics
, and inside the resolver you can accessPost
and handlemixData
. See https://www.gatsbyjs.org/docs/schema-customization/#createresolvers-apiHi @maxkoretskyi. No, there’s not currently a way to access that data at runtime. It’s something people have requested, but couldn’t be implemented without running a live GraphQL server for each site.
I’m going to close this now. If you have any more questions, let me know.