在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):genie-team/graphql-genie开源软件地址(OpenSource Url):https://github.com/genie-team/graphql-genie开源编程语言(OpenSource Language):TypeScript 96.5%开源软件介绍(OpenSource Introduction):GraphQL Genie
OverviewSimply pass in your GraphQL type defintions and get a fully featured GraphQL API with referential integrity, inverse updates, subscriptions and role based access control that can be used client side or server side.
In short GraphQL Genie handles creating the root Query, Mutation and Subscription types and resolvers for a variety of data stores. If that doesn't mean anything to you it may be good to read up on some graphql basics or learn by experimenting with the demo Installation
or
DemoSee the fully featured demo. Create a schema (or use the default provided) and a fully featured api is created. Click the search icon to use GraphiQL to view docs and create or mock data. See graphql genie client on github for more info on the demo. Or for a server demo see the server examples. Getting started
import indexedDBAdapter from 'fortune-mongodb';
import { GraphQLSchema } from 'graphql';
import { FortuneOptions, GraphQLGenie } from 'graphql-genie';
//adapter: configuration array for the data store. The default type is the memory adapter. See below for other adapter options
const fortuneOptions: FortuneOptions = {
// see the documentation for your specific adapter
adapter: [
mongodbAdapter,
{
// options object, URL is mandatory.
url: config.mongodbURL
}
]
};
// Instantiate Genie with your type defintions as a string
const typeDefs = `
type City {
id: ID! @unique
name: String!
neighborhoods: [String] @unique
residents: [User] @relation(name: "city")
founded: Date
population: Int
}
type User {
id: ID! @unique
displayname: String @unique
email: String! @unique
location: City @relation(name: "city")
}`;
const genie = new GraphQLGenie({
typeDefs: typeDefs,
fortuneOptions: fortuneOptions
});
// get the schema and use it with any other tools you want
const schema: GraphQLSchema = genie.getSchema(); Documentation and FeaturesSchema Defining, Altering and MigrationsData Store OptionsGraphQLGenie uses FortuneJS for accessing the data store. This means any fortune adapter will work, plugins currently exist for memory (example), localforage, IndexedDB (example), MongoDB (example), PostgreSQL (example), Redis (examples), Google Cloud Datastore, NeDB and File System. Or you could write your own adapter. GraphQL Genie Schema API (queries and mutations)
GraphQLGenie APIThe api documentation can be found in the docs folder SubscriptionsGraphQL Genie also supports subscriptions with the subscriptions plugin. AuthenticationCheckout the authentication plugin to easily implement role based access control down to individual fields. See the apollo server 2 redis jwt example for JWT authentication with users stored in the database. Uses Apollo Server 2. See the yoga redis example for session authentication with users stored in the database. See the yoga redis firebase example for using firebase authentication to login and control access from an external JWT provider. Of course Genie creates a normal schema so you can add authentication in any other way you want. (the authentication plugin uses a combination of all of these)
How do I do/add [thing]You can use the methods on the GraphQLSchemaBuilder (returned by getSchemaBuilder()) to add types and resolvers 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 or discussion feel free to ask on stack overflow (tag with graphql-genie) or chat on discord ExamplesClientMemorySets up an API that stores data in browser memory IndexedDBSets up an API that stores data in browser Indexed DB ServerApollo Server 2 Redis with JWT AuthenticationSets up a server using Apollo Server 2 and an api that stores to a mock Redis with json web token based signup and login. Uses the authentication plugin for role based access control. GrapqhQL Yoga Redis with Session AuthenticationSets up a server using GrapqhQL Yoga and an api that stores to a mock Redis with session based signup and login. Uses the authentication plugin for role based access control. GrapqhQL Yoga Redis with Firebase AuthenticationSets up a server using GrapqhQL Yoga and an api that stores to a mock Redis. Serves static html for firebase signup and login. Uses the authentication plugin for role based access control. GraphQL Yoga PostgreSQLSets up a server using GrapqhQL Yoga and an API that stores to PostgreSQL. OtherMongoDBCreates a simple node script that uses the GraphQL Genie api to store in a MongoDB database Features/Advantages/DifferencesGraphQL 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.
Roadmap
Changelog
Contribute or Donate
Backers[Your Name and link Here] If you contribute and want a thanks callout on genie project READMEs let me know via twitter message (at least 1.00/month). Thanks so much! Thanks/CreditPrisma GraphQL / Graphcool for inspiration FortuneJS for CRUD adapters Logo Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论