@platformatic/sql-graphql
Advanced tools
Comparing version 0.31.1 to 0.32.0
@@ -50,4 +50,8 @@ 'use strict' | ||
// sqlite doesn't support enums | ||
// PG does support Arrays as columns | ||
/* istanbul ignore next */ | ||
if (field.enum) { | ||
if (field.isArray) { | ||
const listType = sqlTypeToGraphQL(field.sqlType) | ||
meta.type = new graphql.GraphQLList(listType) | ||
} else if (field.enum) { | ||
const enumValues = field.enum.reduce((acc, enumValue, index) => { | ||
@@ -104,16 +108,26 @@ let key = enumValue.replace(/[^\w\s]/g, '_') | ||
const whereFields = Object.keys(fields).reduce((acc, field) => { | ||
let graphqlFields | ||
/* istanbul ignore else */ | ||
if (!fields[field].field.isArray) { | ||
graphqlFields = { | ||
eq: { type: fields[field].type }, | ||
neq: { type: fields[field].type }, | ||
gt: { type: fields[field].type }, | ||
gte: { type: fields[field].type }, | ||
lt: { type: fields[field].type }, | ||
lte: { type: fields[field].type }, | ||
like: { type: fields[field].type }, | ||
in: { type: new graphql.GraphQLList(fields[field].type) }, | ||
nin: { type: new graphql.GraphQLList(fields[field].type) } | ||
} | ||
} else { | ||
graphqlFields = { | ||
any: { type: fields[field].type.ofType }, | ||
all: { type: fields[field].type.ofType } | ||
} | ||
} | ||
acc[field] = { | ||
type: new graphql.GraphQLInputObjectType({ | ||
name: `${entityName}WhereArguments${field}`, | ||
fields: { | ||
eq: { type: fields[field].type }, | ||
neq: { type: fields[field].type }, | ||
gt: { type: fields[field].type }, | ||
gte: { type: fields[field].type }, | ||
lt: { type: fields[field].type }, | ||
lte: { type: fields[field].type }, | ||
like: { type: fields[field].type }, | ||
in: { type: new graphql.GraphQLList(fields[field].type) }, | ||
nin: { type: new graphql.GraphQLList(fields[field].type) } | ||
} | ||
fields: graphqlFields | ||
}) | ||
@@ -168,4 +182,7 @@ } | ||
values: Object.keys(fields).reduce((acc, field) => { | ||
acc[field] = { | ||
value: field | ||
/* istanbul ignore else */ | ||
if (!fields[field].isArray) { | ||
acc[field] = { | ||
value: field | ||
} | ||
} | ||
@@ -172,0 +189,0 @@ return acc |
{ | ||
"name": "@platformatic/sql-graphql", | ||
"version": "0.31.1", | ||
"version": "0.32.0", | ||
"description": "Map SQL dbs to GraphQL", | ||
@@ -25,4 +25,4 @@ "main": "index.js", | ||
"ws": "^8.13.0", | ||
"@platformatic/sql-events": "0.31.1", | ||
"@platformatic/sql-mapper": "0.31.1" | ||
"@platformatic/sql-events": "0.32.0", | ||
"@platformatic/sql-mapper": "0.32.0" | ||
}, | ||
@@ -29,0 +29,0 @@ "dependencies": { |
# @platformatic/sql-graphql | ||
Check out the full documentation on [our website](https://oss.platformatic.dev/docs/reference/sql-graphql/queries). | ||
Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/sql-graphql/queries). | ||
@@ -5,0 +5,0 @@ ## Install |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276297
37
10854