From 15462dd75c5bb7edaa938b9605874438942d7c06 Mon Sep 17 00:00:00 2001 From: Kado Date: Wed, 20 Dec 2023 10:26:13 +0100 Subject: [PATCH] feat: support graphQL annotations --- examples/43-assign-field-annotations.js | 13 +++++++++++++ src/lib/interfaces/annotation.ts | 22 ++++++++++++++++++++++ test/integration/migration.spec.js | 13 +++++++++++++ 3 files changed, 48 insertions(+) diff --git a/examples/43-assign-field-annotations.js b/examples/43-assign-field-annotations.js index b4ac21ca5..ceacfe464 100644 --- a/examples/43-assign-field-annotations.js +++ b/examples/43-assign-field-annotations.js @@ -1,4 +1,17 @@ module.exports = function (migration) { const annotatedContentType = migration.editContentType('annotated') annotatedContentType.editField('sources').setAnnotations(['Contentful:AggregateComponent']) + annotatedContentType.editField('title').setAnnotations([ + { + sys: { + type: 'Link', + linkType: 'Annotation', + id: 'Contentful:GraphQLFieldResolver' + }, + parameters: { + appFunctionId: '123', + appDefinitionId: '456' + } + } + ]) } diff --git a/src/lib/interfaces/annotation.ts b/src/lib/interfaces/annotation.ts index 33b13d436..498e72540 100644 --- a/src/lib/interfaces/annotation.ts +++ b/src/lib/interfaces/annotation.ts @@ -94,6 +94,28 @@ export const availableAnnotations = { ] } ] + }), + 'Contentful:GraphQLFieldResolver': new Annotation({ + id: 'Contentful:GraphQLFieldResolver', + targets: [ + { + type: 'ContentTypeField', + accept: [ + { + type: 'Symbol' + }, + { + type: 'Array', + items: { + type: 'Symbol' + } + }, + { + type: 'Object' + } + ] + } + ] }) } diff --git a/test/integration/migration.spec.js b/test/integration/migration.spec.js index 96e1819de..7823e8852 100644 --- a/test/integration/migration.spec.js +++ b/test/integration/migration.spec.js @@ -1217,6 +1217,19 @@ describe('the migration', function () { linkType: 'Annotation' } } + ], + title: [ + { + sys: { + type: 'Link', + linkType: 'Annotation', + id: 'Contentful:GraphQLFieldResolver' + }, + parameters: { + appFunctionId: '123', + appDefinitionId: '456' + } + } ] } }