GraphQL unresolved data-model
See original GitHub issueI am having issues with rendering data from GraphQL into react since the links are unresolved…
When using this plugin with the contentful.js
module it works great because everything is resolved in rich-text.
We tried to use the graphql
api and everything is unresolved. I wrote a weird thing to manually resolve things myself, but I would love to see if you guys already have something that either does this for us (through this plugin, or another by Contentful).
Is there a way we can either resolve the linked content, or pass in the whole field from graphql to have the renderer resolve these?
Below is the logic route we took and the problem we face.
// get data from Contentful with GraphQL
const entry = await fetchWithGraphQL(`
query {
articleCollection (limit: 1) {
body {
json
links {
entries {
block {
... on CaptionBlock {
__typename
title
sys {
id
}
youGetTheIdea
}
}
}
}
}
}
}`)
// Render data. This is where I wonder if we need to resolve the graphql data ourselves first...
const Component = ({ entry }) => (
<div>
{documentToReactComponents(entry.body.json, contentfulRichTextOptons)}
</div>
)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Spring for GraphQL Documentation
If an exception remains unresolved, by default it is categorized as an INTERNAL_ERROR with a generic message that includes the category name and ......
Read more >GraphQL Content API - Contentful
The GraphQL Content API provides a GraphQL API interface to the content from Contentful. Each Contentful space comes with a GraphQL schema based...
Read more >Modeling GraphQL Mutations - commercetools tech
GraphQL mutations provide a flexible way for a client to modify data on ... a quite simple concept: it separates read and write...
Read more >Data model and resolvers - apischema
None / Optional : Types are non-null (marked with an exclamation mark ! in GraphQL schema) by default; Optional types however results in...
Read more >GraphQL Federation: A Model-Based approach
Abstract The Graph Query Language (GraphQL) is a framework for de- ... This generally requires a canonical data model [CDT18]. In a Microservice....
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
I thought about doing this, but I figured there had to be a better way/something I was missing in the documentation. Apparently not. If the maintainers read this, please give us an easier way to use this library with GraphQL!
@pybuche Sure thing, basically the idea is to pull the entry ID from the node then you find the entry from the links you pass in to your function separately: