feat: Add Cross-Space Reference Resolution Support#332
Conversation
Ely Lucas (elylucasctfl)
left a comment
There was a problem hiding this comment.
Couple of questions with the version one being the main, if you think its good let me know and I'll reapprove
| <groupId>com.contentful.java</groupId> | ||
| <artifactId>java-sdk</artifactId> | ||
| <version>10.5.26</version> | ||
| <version>10.5.27</version> |
There was a problem hiding this comment.
wouldn't this be a minor bump since its a new feature?
There was a problem hiding this comment.
Fixed
| Cross-Space References | ||
| ---------------------- | ||
|
|
||
| The SDK supports resolving cross-space references, which allows you to link content across multiple spaces. When cross-space tokens are configured, entries and assets from other spaces will be automatically included in the response's `includes` section and resolved by the SDK's link resolution. |
There was a problem hiding this comment.
Perhaps we should add the version new features are available in, maybe "In version 10.6.0 and later, the sdk supports..."
There was a problem hiding this comment.
Fixed
| // Add cross-space resolution header if tokens are configured | ||
| if (crossSpaceTokens != null && !crossSpaceTokens.isEmpty()) { | ||
| String encodedHeader = encodeCrossSpaceTokens(crossSpaceTokens); | ||
| okBuilder.addInterceptor(new HeaderInterceptor( | ||
| "x-contentful-resource-resolution", encodedHeader)); | ||
| } |
There was a problem hiding this comment.
have actual cross-space requests been tested using this new interceptor? I had been able to add an interceptor by creating my own OkHttpClient, but when I would run the code, I'd get errors like:
com.contentful.java.cda.CDAContentTypeNotFoundException: Could not find content type 'myContentType' for resource with id '...entryId...' of type 'CDAEntry’.
…
Caused by: com.contentful.java.cda.CDAResourceNotFoundException: Could not find id 'myContentType' of type 'CDAContentType’.
noting that myContentType exists in the remote space but not in the one directly being queried
There was a problem hiding this comment.
There was an issue with the resource factory, thanks for catching it!
| if (client.hasCrossSpaceTokens) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
I get what's going on here. if the client isn't able to cache the type, it's likely it's because that type is in a different space. OTOH, it could be a race and the type was removed, which would be a valid error. dunno if you have a good way to sort between the two. thanks!
Implements support for cross-space references via the
x-contentful-resource-resolution header, enabling automatic resolution of entries/assets from other spaces.Changes:
x-contentful-resource-resolutionheader when tokens are configured