@easy-cms/plugin-graphql 1.28.0 → 1.29.0

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -5
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -317,11 +317,18 @@ var INFO = {
317
317
  name: "@easy-cms/plugin-graphql",
318
318
  // The plugin API it is written for (`PLUGIN_API_VERSION` of @easy-cms/core).
319
319
  apiVersion: 1,
320
- ...true ? { version: "1.28.0" } : {}
320
+ ...true ? { version: "1.29.0" } : {}
321
321
  };
322
322
 
323
323
  // src/schema.ts
324
- import { API_KEYS, INTERNAL_COLLECTIONS, MEDIA, MEDIA_FOLDERS } from "@easy-cms/core/internal";
324
+ import {
325
+ API_KEYS,
326
+ INTERNAL_COLLECTIONS,
327
+ isPolymorphic,
328
+ MEDIA,
329
+ MEDIA_FOLDERS,
330
+ relationTargets
331
+ } from "@easy-cms/core/internal";
325
332
  import {
326
333
  GraphQLBoolean,
327
334
  GraphQLEnumType,
@@ -771,6 +778,7 @@ var Builder = class {
771
778
  return { type: many(this.selectType(field, path) ?? GraphQLString) };
772
779
  case "relationship":
773
780
  case "upload":
781
+ if (isPolymorphic(field)) return { type: hasMany(field) ? list(JSONScalar) : JSONScalar };
774
782
  return this.relationField(field);
775
783
  case "group": {
776
784
  const type = new GraphQLObjectType({
@@ -845,7 +853,7 @@ var Builder = class {
845
853
  return type;
846
854
  }
847
855
  relationField(field) {
848
- const target = field.type === "upload" ? MEDIA : field.to;
856
+ const target = relationTargets(field)[0];
849
857
  const many = hasMany(field);
850
858
  const type = this.objects.get(target);
851
859
  if (!type || !this.exposed(target)) {
@@ -928,7 +936,7 @@ var Builder = class {
928
936
  return this.filters.DateTime;
929
937
  case "relationship":
930
938
  case "upload":
931
- return this.filters.ID;
939
+ return isPolymorphic(field) ? void 0 : this.filters.ID;
932
940
  case "select": {
933
941
  const type = this.selectType(field, path);
934
942
  if (!type) return this.filters.String;
@@ -1184,7 +1192,7 @@ var Builder = class {
1184
1192
  return many(this.selectType(field, path) ?? GraphQLString);
1185
1193
  case "relationship":
1186
1194
  case "upload":
1187
- return many(GraphQLID);
1195
+ return isPolymorphic(field) ? many(JSONScalar) : many(GraphQLID);
1188
1196
  case "blocks":
1189
1197
  return list(JSONScalar);
1190
1198
  case "group":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/plugin-graphql",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "GraphQL API for Easy CMS: queries and mutations for every collection and global, with the same access rules as REST (experimental)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,13 +20,13 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "graphql": "^16.11.0 || ^17.0.0",
23
- "@easy-cms/core": "^1.28.0"
23
+ "@easy-cms/core": "^1.29.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "graphql": "^17.0.2",
27
27
  "graphql-16": "npm:graphql@^16.14.2",
28
- "@easy-cms/core": "^1.28.0",
29
- "@easy-cms/db-sqlite": "^1.28.0"
28
+ "@easy-cms/core": "^1.29.0",
29
+ "@easy-cms/db-sqlite": "^1.29.0"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=22.12"