Closed ptbrowne closed 11 months ago
I don't think that's the case. IDs have always been required, and they've always been strings. Take a look at https://www.datocms.com/docs/next-js/rendering-structured-text-fields#rendering-special-nodes
Are you writing your GraphQL queries like that (notice the id
inside ImageBlockRecord
and BlogPostRecord
)?
const HOMEPAGE_QUERY = `query HomePage($limit: IntType) {
allBlogPosts(first: $limit) {
id
title
content {
value
blocks {
__typename
... on ImageBlockRecord {
id
image { url alt }
}
}
links {
__typename
... on BlogPostRecord {
id
slug
title
}
}
}
}
}`;
You're right 😅 It seems like I had missed to add an "id" inside my query for a newer model. Thanks a lot 🙇
It seems like newly created Records are not assignable to the Record type in dato-cms-structured-text-utils, presumably because the id system has changed.
I am using generated types from the Graphql endpoint and generated types for newer records do not have an id.
It leads to this type of error since I am using the StructuredTextGraphqlResponse type:
It seems like the type here need to be updated https://github.com/datocms/structured-text/blob/3307cbdf9011af162b88ea8ff6cd9ad111b09270/packages/utils/src/types.ts#L454 to mark the id field as optional.
Am I correct ?