Closed angeloashmore closed 3 years ago
Great call! I'm currently investigating rich text output as current definition proved weak when working on helpers (https://github.com/prismicio/prismic-types/blob/master/src/fields.ts#L7), I also have integration fields to check on my plate ^^'
I added this since I needed it in gatsby-source-prismic
but the implementation isn't ideal.
DataInterface
defaults to never
rather than something like PrismicDocument['data']
since it would result in a type circular reference (links circularly referencing other links). TypeScript would not compile.
Basically, the current implementation requires a user to define the type of data if it is to be used. I think this is reasonable since users who use fetchLinks
or graphQuery
know exactly what kind of shape they requested. Typing it to be general by default (i.e. a record of any field type) may not be helpful.
This is totally open to being changed if there's a better way of handling it. 🙂
Is your feature request related to a problem? Please describe.
The
data
field does not exist onRelationField
. Using the REST API, one can query for a document usingfetchLinks
orgraphQuery
. This populates thedata
field on the document.Currently, we can only create a field type like the following:
data
on MyField does not exist, causing the line withMyFieldData
to throw a type error.Describe the solution you'd like
The ability to provide the
data
field's type via a third generic could solve this.