@platformatic/sql-graphql 3.59.0 → 3.60.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.
@@ -1,6 +1,7 @@
1
1
  import { findNearestString } from '@platformatic/foundation'
2
2
  import camelcase from 'camelcase'
3
3
  import {
4
+ GraphQLBoolean,
4
5
  GraphQLEnumType,
5
6
  GraphQLID,
6
7
  GraphQLInputObjectType,
@@ -27,10 +28,23 @@ const limitType = new GraphQLScalarType({
27
28
  'Limit will be applied by default if not passed. If the provided value exceeds the maximum allowed value a validation error will be thrown'
28
29
  })
29
30
 
31
+ const RESERVED_TYPE_NAMES = ['Query', 'Mutation', 'Subscription']
32
+
30
33
  export function constructGraph (app, entity, opts, ignore) {
31
34
  const primaryKeys = Array.from(entity.primaryKeys).map(key => camelcase(key))
32
35
  const relationalFields = entity.relations.map(relation => relation.column_name)
33
- const entityName = entity.name
36
+ let entityName = entity.name
37
+
38
+ // Tables like "queries" or "subscriptions" would generate a type with the
39
+ // same name as a GraphQL root operation type, which is not allowed
40
+ if (RESERVED_TYPE_NAMES.includes(entityName)) {
41
+ const renamed = `${entityName}Entity`
42
+ app.log.warn(
43
+ `The entity "${entityName}" conflicts with a reserved GraphQL root operation type name: ` +
44
+ `its GraphQL type has been renamed to "${renamed}"`
45
+ )
46
+ entityName = renamed
47
+ }
34
48
  const singular = entity.singularName
35
49
  const plural = entity.pluralName
36
50
  const { queryTopFields, mutationTopFields, resolvers, federationReplacements, federationMetadata, loaders } = opts
@@ -138,7 +152,8 @@ export function constructGraph (app, entity, opts, ignore) {
138
152
  lte: { type: fields[field].type },
139
153
  like: { type: fields[field].type },
140
154
  in: { type: new GraphQLList(fields[field].type) },
141
- nin: { type: new GraphQLList(fields[field].type) }
155
+ nin: { type: new GraphQLList(fields[field].type) },
156
+ isNull: { type: GraphQLBoolean }
142
157
  }
143
158
  } else {
144
159
  graphqlFields = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/sql-graphql",
3
- "version": "3.59.0",
3
+ "version": "3.60.0",
4
4
  "description": "Map SQL dbs to GraphQL",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,9 +27,9 @@
27
27
  "typescript": "^5.5.4",
28
28
  "why-is-node-running": "^2.2.2",
29
29
  "ws": "^8.16.0",
30
- "@platformatic/sql-events": "3.59.0",
31
- "@platformatic/sql-mapper": "3.59.0",
32
- "@platformatic/telemetry": "3.59.0"
30
+ "@platformatic/sql-mapper": "3.60.0",
31
+ "@platformatic/sql-events": "3.60.0",
32
+ "@platformatic/telemetry": "3.60.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@fastify/error": "^4.0.0",
@@ -41,7 +41,7 @@
41
41
  "graphql-type-json": "^0.3.2",
42
42
  "inflected": "^2.1.0",
43
43
  "mercurius": "^16.0.0",
44
- "@platformatic/foundation": "3.59.0"
44
+ "@platformatic/foundation": "3.60.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=22.19.0"