Description:
When creating a new custom type via the Custom Types API and then immediately querying documents, the Route Resolver throws an "Unknown type" error for the
newly created type.
Steps to reproduce:
- Create a new custom type (e.g. my_new_type) via the Custom Types API (POST /customtypes)
- Add the type to the routes array passed to
createClient():
{ type: 'my_new_type', path: '/:uid' } - Query any documents whose links reference the new type (e.g.
client.getAllByType('some_existing_type')where documents contain Link fields pointing to my_new_type documents)
Expected behavior: The query succeeds. The new type is immediately available for route resolution.
Actual behavior: The query fails with:
Error: [Link resolver error] Unknown type
Declared type: my_new_type
Expected one of: [list of all previously existing types, but NOT the newly created one]
Workaround: Go to the Prismic UI, open the new custom type, make any change (or just save), and then the query succeeds. This suggests the CDN type registry is only refreshed after a UI-triggered save, not after an API-triggered creation.
Impact: This breaks CI/CD workflows where we sync custom types via the API before building. The sync step creates the type successfully, but the subsequent build fails because the CDN doesn't recognize it yet. We have to manually intervene in the UI after every new type creation, defeating the purpose of API-driven sync.