@payloadcms/graphql 4.0.0-internal.3aa3d85 → 4.0.0-internal.43ccea7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withNullableType.d.ts","sourceRoot":"","sources":["../../src/schema/withNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"withNullableType.d.ts","sourceRoot":"","sources":["../../src/schema/withNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAKjD,eAAO,MAAM,gBAAgB,GAAI,oDAK9B;IACD,KAAK,EAAE,kBAAkB,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,WAAW,CAAA;CAClB,KAAG,WAsBH,CAAA"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { GraphQLNonNull } from 'graphql';
|
|
2
|
+
import { fieldIsVirtual } from 'payload/shared';
|
|
2
3
|
export const withNullableType = ({ type, field, forceNullable, parentIsLocalized })=>{
|
|
3
4
|
const hasReadAccessControl = field.access && field.access.read;
|
|
4
5
|
const condition = field.admin && field.admin.condition;
|
|
5
6
|
const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt';
|
|
6
|
-
|
|
7
|
+
// Virtual fields are computed (by hooks or from a linked relationship), so they must
|
|
8
|
+
// not be non-null in the GraphQL schema even when marked required.
|
|
9
|
+
const isVirtual = fieldIsVirtual(field);
|
|
10
|
+
if (!forceNullable && 'required' in field && field.required && (!field.localized || parentIsLocalized) && !condition && !hasReadAccessControl && !isTimestamp && !isVirtual) {
|
|
7
11
|
return new GraphQLNonNull(type);
|
|
8
12
|
}
|
|
9
13
|
return type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\n\nexport const withNullableType = ({\n type,\n field,\n forceNullable,\n parentIsLocalized,\n}: {\n field: FieldAffectingData\n forceNullable?: boolean\n parentIsLocalized: boolean\n type: GraphQLType\n}): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n (!field.localized || parentIsLocalized) &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n"],"names":["GraphQLNonNull","withNullableType","type","field","forceNullable","parentIsLocalized","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","required","localized"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;
|
|
1
|
+
{"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\nimport { fieldIsVirtual } from 'payload/shared'\n\nexport const withNullableType = ({\n type,\n field,\n forceNullable,\n parentIsLocalized,\n}: {\n field: FieldAffectingData\n forceNullable?: boolean\n parentIsLocalized: boolean\n type: GraphQLType\n}): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n // Virtual fields are computed (by hooks or from a linked relationship), so they must\n // not be non-null in the GraphQL schema even when marked required.\n const isVirtual = fieldIsVirtual(field)\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n (!field.localized || parentIsLocalized) &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp &&\n !isVirtual\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n"],"names":["GraphQLNonNull","fieldIsVirtual","withNullableType","type","field","forceNullable","parentIsLocalized","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","isVirtual","required","localized"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,cAAc,QAAQ,iBAAgB;AAE/C,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,IAAI,EACJC,KAAK,EACLC,aAAa,EACbC,iBAAiB,EAMlB;IACC,MAAMC,uBAAuBH,MAAMI,MAAM,IAAIJ,MAAMI,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYN,MAAMO,KAAK,IAAIP,MAAMO,KAAK,CAACD,SAAS;IACtD,MAAME,cAAcR,MAAMS,IAAI,KAAK,eAAeT,MAAMS,IAAI,KAAK;IACjE,qFAAqF;IACrF,mEAAmE;IACnE,MAAMC,YAAYb,eAAeG;IAEjC,IACE,CAACC,iBACD,cAAcD,SACdA,MAAMW,QAAQ,IACb,CAAA,CAACX,MAAMY,SAAS,IAAIV,iBAAgB,KACrC,CAACI,aACD,CAACH,wBACD,CAACK,eACD,CAACE,WACD;QACA,OAAO,IAAId,eAAeG;IAC5B;IAEA,OAAOA;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/graphql",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.43ccea7",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@types/pluralize": "^0.0.33",
|
|
54
54
|
"graphql-http": "1.22.4",
|
|
55
55
|
"@payloadcms/eslint-config": "3.28.0",
|
|
56
|
-
"payload": "4.0.0-internal.
|
|
56
|
+
"payload": "4.0.0-internal.43ccea7"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"graphql": "^16.8.1",
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
60
|
+
"payload": "4.0.0-internal.43ccea7"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm build:types && pnpm build:swc",
|