Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@adamvr/joiql
Advanced tools
Make GraphQL schema creation and data validation easy with Joi.
Run this using node example
...
const joiql = require('joiql')
const { object, string, number, array, date } = require('joi')
const app = require('express')()
const graphqlHTTP = require('express-graphql')
// Joi Schemas
const Film = object({
title: string(),
producers: array().items(string()),
release_date: date()
})
const Person = object({
name: string(),
films: array().items(Film)
}).meta({
args: { id: number().required() },
resolve: (root, args, req, ast) => ({ name: 'Spike Jonze' })
})
// Convert Joi schemas to GraphQL
const schema = joiql({
query: {
person: Person,
film: Film
}
})
// Mount schema to express
app.use('/', graphqlHTTP({ schema: schema, graphiql: true }))
app.listen(3000, () => console.log('listening on 3000'))
First, define some schemas using Joi.
const { object, string, number, array, date } = require('joi')
const Film = object({
title: string(),
producers: array().items(string()),
releaseDate: date()
})
const Person = object({
name: string(),
films: array().items(Film)
})
JoiQL uses the meta
property to extend GraphQL fields. Use meta.args
to define GraphQL arguments (adding automatic
input validation), and meta.name
to declare the GraphQLObjectType
type name (without it JoiQL will automatically
add a "Anon" type name).
Person.meta({
name: 'Person',
args: { id: number().required() }
})
Then create a JoiQL api
object from the Joi schemas and expose a GraphQL.js schema object for mounting into a server like Express.
const { graphql } = require('graphql')
const joiql = require('../')
const api = joiql({
query: {
person: Person,
film: Film
}
})
graphql(api.schema, ...)
lazy
)Please fork the project and submit a pull request with tests. Install node modules npm install
and run tests with npm test
.
MIT
FAQs
Make GraphQL schema creation and data validation easy with Joi.
The npm package @adamvr/joiql receives a total of 0 weekly downloads. As such, @adamvr/joiql popularity was classified as not popular.
We found that @adamvr/joiql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.