Browse Source

fix(core): Fix error when using internal relation custom fields

Fixes #1416
Michael Bromley 4 years ago
parent
commit
753470a4d2

+ 1 - 0
packages/core/e2e/custom-field-relations.e2e-spec.ts

@@ -74,6 +74,7 @@ customFieldConfig.Product?.push(
     { name: 'cfProductVariant', type: 'relation', entity: ProductVariant, list: false },
     { name: 'cfProduct', type: 'relation', entity: Product, list: false },
     { name: 'cfShippingMethod', type: 'relation', entity: ShippingMethod, list: false },
+    { name: 'cfInternalAsset', type: 'relation', entity: Asset, list: false, internal: true },
 );
 
 const customConfig = mergeConfig(testConfig(), {

+ 4 - 0
packages/core/src/api/config/generate-resolvers.ts

@@ -166,6 +166,10 @@ function generateCustomFieldRelationResolvers(
             };
         }
         for (const fieldDef of relationCustomFields) {
+            if (fieldDef.internal === true) {
+                // Do not create any resolvers for internal relations
+                continue;
+            }
             const relationResolver: IFieldResolver<any, any> = async (
                 source: any,
                 args: any,