Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
graphql-genie
Advanced tools
Write a GraphQL Type Schema and GraphQL Genie automatically generates a fully featured GraphQL API with referential integrity and inverse updates that can be used client side or server side. You can use all the features of the type schema, including interfaces and unions. Add subscriptions with the plugin. The schema uses best practices and is compliant with the Relay GraphQL Server Specification.
See the fully featured demo. Create a schema (or use the default provided) and a fully featured api is created. Click the search to use GraphiQL to view docs and create or mock data. See graphql genie client on github for more info on the demo.
npm install graphql-genie fortune graphql graphql-tools lodash
or yarn add graphql-genie fortune graphql graphql-tools lodash
import { FortuneOptions, GraphQLGenie } from 'graphql-genie';
import mongodbAdapter from 'fortune-mongodb';
//adapter: configuration array for the data store. The default type is the memory adapter. See below for other adapter options
const fortuneOptions: FortuneOptions = {
adapter: [
mongodbAdapter,
{
// options object, URL is mandatory.
url: config.mongodbURL
}
],
settings: { enforceLinks: true }
};
// Instantiate Genie with your type defintions as a string
const typeDefs = `[TYPEDEFS]`
const genie = new GraphQLGenie({
typeDefs: typeDefs,
fortuneOptions: fortuneOptions
});
// init genie, this sets up all the new types and resolvers, init returns a promise so use await or .then()
await genie.init();
// get the schema and use it with any other tools you want
const schema: GraphQLSchema = genie.getSchema();
GraphQLGenie uses FortuneJS for accessing the data store. This means any fortune adapter will work, plugins currently exist for memory (example), IndexedDB (example), MongoDB (example), Postgres (example), Redis, Google Cloud Datastore, NeDB and File System. Or you could write your own.
GraphQL Genie also supports subscriptions with the subscriptions plugin.
The api documentation can be found in the docs folder
Work is in progress on a plugin to make it extremely easy to add Authentication to a schema created with GraphQL Genie. There are a lot of ways to have some sort of authentication with a GraphQL API and Genie gives you the flexibility to do it any way you want or integrate into services such as Auth0 or Firebase.
Some options to add authentication
You can use the methods on the GraphQLSchemaBuilder (returned by getSchemaBuilder()) to add types and re``solvers to the generated schema. Or since it is just a normal schema you can use any tool you want (such as graphql-tools) to alter the schema in any way. Including adding resolvers, mocking, stitching, transforming, etc.
If you want guidance feel free to open an issue and label it as a question.
Additional documentation is in development, see examples and tests for implementation examples.
GraphQL Genie is inspired by Prisma GraphQL and the resulting API has a lot of similarities but they have different goals. Because GraphQL Genie gives you a fully functioning graphql api but is not opinionated about anything else you have the flexibility to use that schema wherever you want and integrate it with any existing services you use.
Prisma GraphQL / Graphcool for inspiration
FortuneJS for CRUD adapters
Logo Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
FAQs
GraphQL Genie
The npm package graphql-genie receives a total of 4 weekly downloads. As such, graphql-genie popularity was classified as not popular.
We found that graphql-genie 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.