I'm working with Contentful's GraphQL API to display our company magazine content natively within our iOS app.
I encountered an issue when decoding Entry links within the body of an article: in the implementation of the library we have a non-optional type field within the Sys object, but in the GraphQL API the Sys type has no such field. Rather, you can find the concrete type of an Entry field by checking the "__typename" field on the Entry itself instead of inside the Sys object.
This PR makes the type field within Sys optional, so that we can still decode an Entry object from the raw JSON payload received via the GraphQL API.
There is also another change: I noticed that we pass the entry.sys.type field value to the Link initializer. This field will contain the name of the concrete entry type, instead of only "Entry" or "Asset" as stated in the documentation comment of the Link.linkType field. I modified the relevant code to pass the string "Entry" instead, in accord with the documentation.
I'm working with Contentful's GraphQL API to display our company magazine content natively within our iOS app.
I encountered an issue when decoding Entry links within the body of an article: in the implementation of the library we have a non-optional
type
field within theSys
object, but in the GraphQL API the Sys type has no such field. Rather, you can find the concrete type of anEntry
field by checking the "__typename" field on the Entry itself instead of inside the Sys object.This PR makes the
type
field within Sys optional, so that we can still decode anEntry
object from the raw JSON payload received via the GraphQL API.There is also another change: I noticed that we pass the
entry.sys.type
field value to theLink
initializer. This field will contain the name of the concrete entry type, instead of only "Entry" or "Asset" as stated in the documentation comment of theLink.linkType
field. I modified the relevant code to pass the string "Entry" instead, in accord with the documentation.