{"version":3,"file":"relation-response-collection.mjs","sources":["../../../../server/src/services/builders/relation-response-collection.ts"],"sourcesContent":["import { objectType, nonNull } from 'nexus';\nimport { defaultTo, prop, pipe } from 'lodash/fp';\nimport type { Schema } from '@strapi/types';\nimport type { Context } from '../types';\n\nexport default ({ strapi }: Context) => {\n  const { naming } = strapi.plugin('graphql').service('utils');\n\n  return {\n    /**\n     * Build a type definition for a content API relation's collection response for a given content type\n     */\n    buildRelationResponseCollectionDefinition(contentType: Schema.ContentType) {\n      const name = naming.getRelationResponseCollectionName(contentType);\n      const typeName = naming.getTypeName(contentType);\n\n      return objectType({\n        name,\n\n        definition(t) {\n          t.nonNull.list.field('nodes', {\n            type: nonNull(typeName),\n\n            resolve: pipe(prop('nodes'), defaultTo([])),\n          });\n\n          if (strapi.plugin('graphql').config('v4CompatibilityMode', false)) {\n            t.nonNull.list.field('data', {\n              deprecation: 'Use `nodes` field instead',\n              type: nonNull(typeName),\n              resolve: pipe(prop('nodes'), defaultTo([])),\n            });\n          }\n        },\n      });\n    },\n  };\n};\n"],"names":["strapi","naming","plugin","service","buildRelationResponseCollectionDefinition","contentType","name","getRelationResponseCollectionName","typeName","getTypeName","objectType","definition","t","nonNull","list","field","type","resolve","pipe","prop","defaultTo","config","deprecation"],"mappings":";;;AAKA,iCAAe,CAAA,CAAC,EAAEA,MAAM,EAAW,GAAA;IACjC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAOE,MAAM,CAAC,SAAWC,CAAAA,CAAAA,OAAO,CAAC,OAAA,CAAA;IAEpD,OAAO;AACL;;AAEC,QACDC,2CAA0CC,WAA+B,EAAA;YACvE,MAAMC,IAAAA,GAAOL,MAAOM,CAAAA,iCAAiC,CAACF,WAAAA,CAAAA;YACtD,MAAMG,QAAAA,GAAWP,MAAOQ,CAAAA,WAAW,CAACJ,WAAAA,CAAAA;AAEpC,YAAA,OAAOK,UAAW,CAAA;AAChBJ,gBAAAA,IAAAA;AAEAK,gBAAAA,UAAAA,CAAAA,CAAWC,CAAC,EAAA;AACVA,oBAAAA,CAAAA,CAAEC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,OAAS,EAAA;AAC5BC,wBAAAA,IAAAA,EAAMH,OAAQL,CAAAA,QAAAA,CAAAA;AAEdS,wBAAAA,OAAAA,EAASC,IAAKC,CAAAA,IAAAA,CAAK,OAAUC,CAAAA,EAAAA,SAAAA,CAAU,EAAE,CAAA;AAC3C,qBAAA,CAAA;AAEA,oBAAA,IAAIpB,OAAOE,MAAM,CAAC,WAAWmB,MAAM,CAAC,uBAAuB,KAAQ,CAAA,EAAA;AACjET,wBAAAA,CAAAA,CAAEC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,MAAQ,EAAA;4BAC3BO,WAAa,EAAA,2BAAA;AACbN,4BAAAA,IAAAA,EAAMH,OAAQL,CAAAA,QAAAA,CAAAA;AACdS,4BAAAA,OAAAA,EAASC,IAAKC,CAAAA,IAAAA,CAAK,OAAUC,CAAAA,EAAAA,SAAAA,CAAU,EAAE,CAAA;AAC3C,yBAAA,CAAA;AACF;AACF;AACF,aAAA,CAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}