@gqloom/json 0.11.0 → 0.12.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.
package/dist/index.cjs CHANGED
@@ -140,8 +140,7 @@ var JSONWeaver = class JSONWeaver {
140
140
  };
141
141
  return JSONWeaver.toGraphQLTypeInner(unwrappedSchema);
142
142
  }
143
- const name = schema.title ?? JSONWeaver.getCollectedName(schema);
144
- if (!name) throw new Error("Union type must have a name");
143
+ const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? __gqloom_core.AUTO_ALIASING;
145
144
  return new graphql.GraphQLUnionType({
146
145
  name,
147
146
  description: schema.description,
@@ -154,8 +153,7 @@ var JSONWeaver = class JSONWeaver {
154
153
  }
155
154
  const type = Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") : schema.type;
156
155
  if (schema.enum) {
157
- const name = schema.title ?? JSONWeaver.getCollectedName(schema);
158
- if (!name) throw new Error("Enum type must have a name");
156
+ const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? __gqloom_core.AUTO_ALIASING;
159
157
  const values = {};
160
158
  for (const value of schema.enum) if (typeof value === "string" || typeof value === "number") {
161
159
  const key = String(value).replace(/[^_a-zA-Z0-9]/g, "_");
@@ -178,7 +176,7 @@ var JSONWeaver = class JSONWeaver {
178
176
  return new graphql.GraphQLList(itemType);
179
177
  }
180
178
  case "object": {
181
- const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? JSONWeaver.getTypeName(schema) ?? __gqloom_core.LoomObjectType.AUTO_ALIASING;
179
+ const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? JSONWeaver.getTypeName(schema) ?? __gqloom_core.AUTO_ALIASING;
182
180
  return new graphql.GraphQLObjectType({
183
181
  name,
184
182
  description: schema.description,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LoomObjectType, SYMBOLS, ensureInterfaceType, mapValue, weaverContext } from "@gqloom/core";
1
+ import { AUTO_ALIASING, SYMBOLS, ensureInterfaceType, mapValue, weaverContext } from "@gqloom/core";
2
2
  import { GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLString, GraphQLUnionType, isNonNullType, isObjectType } from "graphql";
3
3
 
4
4
  //#region src/index.ts
@@ -115,8 +115,7 @@ var JSONWeaver = class JSONWeaver {
115
115
  };
116
116
  return JSONWeaver.toGraphQLTypeInner(unwrappedSchema);
117
117
  }
118
- const name = schema.title ?? JSONWeaver.getCollectedName(schema);
119
- if (!name) throw new Error("Union type must have a name");
118
+ const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? AUTO_ALIASING;
120
119
  return new GraphQLUnionType({
121
120
  name,
122
121
  description: schema.description,
@@ -129,8 +128,7 @@ var JSONWeaver = class JSONWeaver {
129
128
  }
130
129
  const type = Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") : schema.type;
131
130
  if (schema.enum) {
132
- const name = schema.title ?? JSONWeaver.getCollectedName(schema);
133
- if (!name) throw new Error("Enum type must have a name");
131
+ const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? AUTO_ALIASING;
134
132
  const values = {};
135
133
  for (const value of schema.enum) if (typeof value === "string" || typeof value === "number") {
136
134
  const key = String(value).replace(/[^_a-zA-Z0-9]/g, "_");
@@ -153,7 +151,7 @@ var JSONWeaver = class JSONWeaver {
153
151
  return new GraphQLList(itemType);
154
152
  }
155
153
  case "object": {
156
- const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? JSONWeaver.getTypeName(schema) ?? LoomObjectType.AUTO_ALIASING;
154
+ const name = schema.title ?? JSONWeaver.getCollectedName(schema) ?? JSONWeaver.getTypeName(schema) ?? AUTO_ALIASING;
157
155
  return new GraphQLObjectType({
158
156
  name,
159
157
  description: schema.description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gqloom/json",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Create GraphQL schema and resolvers easily using using JSON Schema!",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "author": "xcfox",
33
33
  "license": "MIT",
34
34
  "peerDependencies": {
35
- "@gqloom/core": ">= 0.11.1",
35
+ "@gqloom/core": ">= 0.12.0",
36
36
  "graphql": ">= 16.8.0"
37
37
  },
38
38
  "devDependencies": {
@@ -40,7 +40,7 @@
40
40
  "arktype": "^2.1.22",
41
41
  "effect": "^3.17.13",
42
42
  "typebox": "^1.0.4",
43
- "@gqloom/core": "0.11.1"
43
+ "@gqloom/core": "0.12.0"
44
44
  },
45
45
  "homepage": "https://gqloom.dev/",
46
46
  "repository": {