Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@platformatic/sql-graphql

Package Overview
Dependencies
Maintainers
6
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platformatic/sql-graphql - npm Package Compare versions

Comparing version 0.45.1 to 0.46.1

20

index.js

@@ -8,2 +8,3 @@ 'use strict'

const { mercuriusFederationPlugin } = require('@mercuriusjs/federation')
const { findNearestString } = require('@platformatic/utils')
const establishRelations = require('./lib/relationship')

@@ -41,8 +42,23 @@ const setupSubscriptions = require('./lib/subscriptions')

} else {
const entitiesNames = Object.values(mapper.entities)
.map(entity => entity.singularName)
for (const ignoredEntity of Object.keys(ignore)) {
if (!entitiesNames.includes(ignoredEntity)) {
const nearestEntity = findNearestString(entitiesNames, ignoredEntity)
let warningMessage = `Ignored graphql entity "${ignoredEntity}" not found.`
/* istanbul ignore next */
if (nearestEntity) {
warningMessage += ` Did you mean "${nearestEntity}"?`
}
app.log.warn(warningMessage)
}
}
for (const entity of Object.values(mapper.entities)) {
if (ignore[entity.pluralName] === true) {
if (ignore[entity.singularName] === true) {
continue
}
relations.push(...entity.relations)
const meta = constructGraph(app, entity, graphOpts, ignore[entity.pluralName] || {})
const meta = constructGraph(app, entity, graphOpts, ignore[entity.singularName] || {})
metaMap.set(entity, meta)

@@ -49,0 +65,0 @@ }

@@ -5,2 +5,3 @@ 'use strict'

const camelcase = require('camelcase')
const { findNearestString } = require('@platformatic/utils')
const {

@@ -41,2 +42,15 @@ sqlTypeToGraphQL,

const entityFieldsNames = Object.values(entity.fields)
.map(field => field.camelcase)
for (const ignoredField of Object.keys(ignore)) {
if (!entityFieldsNames.includes(ignoredField)) {
const nearestField = findNearestString(entityFieldsNames, ignoredField)
app.log.warn(
`Ignored graphql field "${ignoredField}" not found in entity "${entity.singularName}".` +
` Did you mean "${nearestField}"?`
)
}
}
const fields = {}

@@ -43,0 +57,0 @@

9

package.json
{
"name": "@platformatic/sql-graphql",
"version": "0.45.1",
"version": "0.46.1",
"description": "Map SQL dbs to GraphQL",

@@ -25,4 +25,4 @@ "main": "index.js",

"ws": "^8.13.0",
"@platformatic/sql-events": "0.45.1",
"@platformatic/sql-mapper": "0.45.1"
"@platformatic/sql-events": "0.46.1",
"@platformatic/sql-mapper": "0.46.1"
},

@@ -38,3 +38,4 @@ "dependencies": {

"inflected": "^2.1.0",
"mercurius": "^13.0.0"
"mercurius": "^13.0.0",
"@platformatic/utils": "0.46.1"
},

@@ -41,0 +42,0 @@ "tsd": {

@@ -132,3 +132,3 @@ 'use strict'

ignore: {
categories: true
category: true
}

@@ -162,2 +162,42 @@ })

test('show a warning if there is no ignored entity', async ({ plan, pass, teardown }) => {
plan(2)
const app = fastify({
logger: {
info () {},
debug () {},
trace () {},
fatal () {},
error () {},
child () {
return this
},
warn (msg) {
if (msg === 'Ignored graphql entity "missingEntityPages" not found. Did you mean "page"?') {
pass('warning message is shown')
}
}
}
})
app.register(sqlMapper, {
...connInfo,
async onDatabaseLoad (db, sql) {
pass('onDatabaseLoad called')
await clear(db, sql)
await createBasicPages(db, sql)
}
})
app.register(sqlGraphQL, {
ignore: {
missingEntityPages: true
}
})
teardown(app.close.bind(app))
await app.ready()
})
test('ignore a column via sql-graphql option', async ({ pass, teardown, equal }) => {

@@ -176,3 +216,3 @@ const app = fastify()

ignore: {
categories: {
category: {
name: true

@@ -211,1 +251,43 @@ }

})
test('show a warning if there is no ignored entity field', async ({ plan, pass, teardown }) => {
plan(2)
const app = fastify({
logger: {
info () {},
debug () {},
trace () {},
fatal () {},
error () {},
child () {
return this
},
warn (msg) {
if (msg === 'Ignored graphql field "missingFieldName" not found in entity "category". Did you mean "name"?') {
pass('warning message is shown')
}
}
}
})
app.register(sqlMapper, {
...connInfo,
async onDatabaseLoad (db, sql) {
pass('onDatabaseLoad called')
await clear(db, sql)
await createBasicPages(db, sql)
}
})
app.register(sqlGraphQL, {
ignore: {
category: {
missingFieldName: true
}
}
})
teardown(app.close.bind(app))
await app.ready()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc