graphql-genie
Advanced tools
Comparing version 0.4.17 to 0.4.18
@@ -72,2 +72,4 @@ - [GraphQLGenie API](#graphqlgenie-api) | ||
Make sure to call getSchema() after all uses of `use` | ||
> See info about the GeniePlugin interface in [GraphQLGenieInterfaces.ts](https://github.com/genie-team/graphql-genie/blob/master/src/GraphQLGenieInterfaces.ts) | ||
@@ -74,0 +76,0 @@ |
import { IntrospectionType } from 'graphql'; | ||
import { Connection, DataResolver, DataResolverInputHook, DataResolverOutputHook, Features, FortuneOptions } from './GraphQLGenieInterfaces'; | ||
import { Connection, DataResolver, DataResolverInputHook, DataResolverOutputHook, Features, FortuneOptions, FortuneRecordTypeDefinitions } from './GraphQLGenieInterfaces'; | ||
interface FortuneUpdate { | ||
@@ -18,3 +18,3 @@ id: string; | ||
private transaction; | ||
constructor(fortuneOptions: FortuneOptions, schemaInfo: IntrospectionType[]); | ||
constructor(fortuneOptions: FortuneOptions, schemaInfo: IntrospectionType[], fortuneRecordTypeDefinitions?: FortuneRecordTypeDefinitions); | ||
computeId: (graphType: string, id?: string) => string; | ||
@@ -21,0 +21,0 @@ getTypeFromId: (inputId: string) => string; |
@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import fortune from 'fortune'; | ||
import { each, find, findIndex, forOwn, get, has, isArray, isEmpty, isEqual, isPlainObject, isString, keys, set, toString } from 'lodash'; | ||
import { each, find, findIndex, forOwn, get, has, isArray, isEmpty, isEqual, isPlainObject, isString, keys, merge, set, toString } from 'lodash'; | ||
import fortuneCommon from 'fortune/lib/adapter/adapters/common'; | ||
@@ -17,3 +17,3 @@ import { Connection } from './GraphQLGenieInterfaces'; | ||
export default class FortuneGraph { | ||
constructor(fortuneOptions, schemaInfo) { | ||
constructor(fortuneOptions, schemaInfo, fortuneRecordTypeDefinitions) { | ||
this.computeId = (graphType, id) => { | ||
@@ -375,3 +375,3 @@ id = id || fortuneCommon.generateId(); | ||
}; | ||
this.buildFortune = () => { | ||
this.buildFortune = (fortuneRecordTypeDefinitions) => { | ||
this.computeFortuneTypeNames(); | ||
@@ -477,2 +477,5 @@ const relations = computeRelations(this.schemaInfo, this.getFortuneTypeName); | ||
}); | ||
if (fortuneRecordTypeDefinitions) { | ||
merge(fortuneConfig, fortuneRecordTypeDefinitions); | ||
} | ||
const store = fortune(fortuneConfig, this.fortuneOptions); | ||
@@ -525,3 +528,3 @@ return store; | ||
this.outputHooks = new Map(); | ||
this.store = this.buildFortune(); | ||
this.store = this.buildFortune(fortuneRecordTypeDefinitions); | ||
} | ||
@@ -528,0 +531,0 @@ getDataTypeName(graphQLTypeName) { |
@@ -6,2 +6,3 @@ import { GraphQLSchema, IntrospectionQuery, IntrospectionType } from 'graphql'; | ||
private fortuneOptions; | ||
private fortuneRecordTypeDefinitions; | ||
private config; | ||
@@ -8,0 +9,0 @@ private generators; |
@@ -59,3 +59,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.relations = computeRelations(this.schemaInfo); | ||
this.graphQLFortune = new FortuneGraph(this.fortuneOptions, this.schemaInfo); | ||
this.graphQLFortune = new FortuneGraph(this.fortuneOptions, this.schemaInfo, this.fortuneRecordTypeDefinitions); | ||
this.buildQueries(); | ||
@@ -547,2 +547,3 @@ this.buildResolvers(); | ||
} | ||
this.fortuneRecordTypeDefinitions = options.fortuneRecordTypeDefinitions; | ||
if (options.generatorOptions) { | ||
@@ -549,0 +550,0 @@ this.config = Object.assign(this.config, options.generatorOptions); |
@@ -61,2 +61,3 @@ import { DocumentNode, GraphQLFieldResolver } from 'graphql'; | ||
fortuneOptions?: FortuneOptions; | ||
fortuneRecordTypeDefinitions?: FortuneRecordTypeDefinitions; | ||
plugins?: GeniePlugin[] | GeniePlugin; | ||
@@ -75,2 +76,7 @@ } | ||
} | ||
export interface FortuneRecordTypeDefinitions { | ||
[key: string]: { | ||
[property: string]: any; | ||
}; | ||
} | ||
export interface GeniePlugin { | ||
@@ -77,0 +83,0 @@ (genie: GraphQLGenie): any; |
{ | ||
"name": "graphql-genie", | ||
"version": "0.4.17", | ||
"version": "0.4.18", | ||
"description": "GraphQL Genie", | ||
@@ -42,3 +42,4 @@ "browser": "./lib/browser.umd.js", | ||
"lint-no-fix": "tslint -c tslint.json -p linttsconfig.json", | ||
"tag": "git tag -a v`npm v graphql-genie version` && git push origin --tags" | ||
"tag": "git tag -a v`npm v graphql-genie version` && git push origin --tags", | ||
"installPluginDevDependencies": "cd plugins/genie-persistence && yarn install" | ||
}, | ||
@@ -45,0 +46,0 @@ "jest": { |
@@ -49,3 +49,2 @@ <h1 align="center"> | ||
- **FortuneJS Storage** allows many storage options and the ability to easily create your own. See [data store options](#data-store-options) | ||
@@ -221,4 +220,7 @@ In short GraphQL Genie handles creating the root Query, Mutation and Subscription types and resolvers for a variety of [data stores](#data-store). If that doesn't mean anything to you it may be good to read up on some [graphql basics](https://www.okgrow.com/posts/graphql-basics) or learn by experimenting with the [demo](https://genie-team.github.io/graphql-genie-client/) | ||
## Roadmap | ||
* Genie Persistence Plugin - will work with apollo client to work offline and persist to the database when it's available | ||
* Performance improvements - send info for all necessary queries to fortune so it can handle in less requests, and make sure genie properly handles return of that additional data | ||
* Progressive Web App example | ||
* More advanced migration and build process features | ||
* **Production Ready?** I would not say Genie is production ready yet, there has not been a lot of actual use yet since it is so new. Almost to a point where I will share it more widely which will help. I plan on using it in a production (although low risk) project in late 2018. | ||
@@ -225,0 +227,0 @@ ## Changelog |
import { atob, btoa } from 'abab'; | ||
import fortune from 'fortune'; | ||
import { IntrospectionInterfaceType, IntrospectionType } from 'graphql'; | ||
import { each, find, findIndex, forOwn, get, has, isArray, isEmpty, isEqual, isPlainObject, isString, keys, set, toString } from 'lodash'; | ||
import { each, find, findIndex, forOwn, get, has, isArray, isEmpty, isEqual, isPlainObject, isString, keys, merge, set, toString } from 'lodash'; | ||
import fortuneCommon from 'fortune/lib/adapter/adapters/common'; | ||
import { Connection, DataResolver, DataResolverInputHook, DataResolverOutputHook, Features, FortuneOptions, GenericObject } from './GraphQLGenieInterfaces'; | ||
import { Connection, DataResolver, DataResolverInputHook, DataResolverOutputHook, Features, FortuneOptions, FortuneRecordTypeDefinitions, GenericObject } from './GraphQLGenieInterfaces'; | ||
import { computeRelations } from './TypeGeneratorUtilities'; | ||
@@ -25,3 +25,3 @@ | ||
private transaction; | ||
constructor(fortuneOptions: FortuneOptions, schemaInfo: IntrospectionType[]) { | ||
constructor(fortuneOptions: FortuneOptions, schemaInfo: IntrospectionType[], fortuneRecordTypeDefinitions?: FortuneRecordTypeDefinitions) { | ||
this.fortuneOptions = fortuneOptions; | ||
@@ -35,3 +35,3 @@ if (!this.fortuneOptions || !this.fortuneOptions.hooks) { | ||
this.outputHooks = new Map<string, DataResolverOutputHook[]>(); | ||
this.store = this.buildFortune(); | ||
this.store = this.buildFortune(fortuneRecordTypeDefinitions); | ||
@@ -415,3 +415,3 @@ } | ||
private buildFortune = () => { | ||
private buildFortune = (fortuneRecordTypeDefinitions?: FortuneRecordTypeDefinitions) => { | ||
this.computeFortuneTypeNames(); | ||
@@ -522,2 +522,5 @@ const relations = computeRelations(this.schemaInfo, this.getFortuneTypeName); | ||
}); | ||
if (fortuneRecordTypeDefinitions) { | ||
merge(fortuneConfig, fortuneRecordTypeDefinitions); | ||
} | ||
const store = fortune(fortuneConfig, this.fortuneOptions); | ||
@@ -524,0 +527,0 @@ return store; |
@@ -11,3 +11,3 @@ | ||
import { GenerateUpsert } from './GenerateUpsert'; | ||
import { DataResolver, FortuneOptions, GenerateConfig, GenericObject, GeniePlugin, GraphQLGenieOptions, TypeGenerator } from './GraphQLGenieInterfaces'; | ||
import { DataResolver, FortuneOptions, FortuneRecordTypeDefinitions, GenerateConfig, GenericObject, GeniePlugin, GraphQLGenieOptions, TypeGenerator } from './GraphQLGenieInterfaces'; | ||
import { GraphQLSchemaBuilder } from './GraphQLSchemaBuilder'; | ||
@@ -23,2 +23,3 @@ import { getReturnType } from './GraphQLUtils'; | ||
private fortuneOptions: FortuneOptions; | ||
private fortuneRecordTypeDefinitions: FortuneRecordTypeDefinitions; | ||
private config: GenerateConfig = { | ||
@@ -50,2 +51,3 @@ generateGetOne: true, | ||
} | ||
this.fortuneRecordTypeDefinitions = options.fortuneRecordTypeDefinitions; | ||
@@ -91,3 +93,3 @@ if (options.generatorOptions) { | ||
this.relations = computeRelations(this.schemaInfo); | ||
this.graphQLFortune = new FortuneGraph(this.fortuneOptions, this.schemaInfo); | ||
this.graphQLFortune = new FortuneGraph(this.fortuneOptions, this.schemaInfo, this.fortuneRecordTypeDefinitions); | ||
this.buildQueries(); | ||
@@ -94,0 +96,0 @@ this.buildResolvers(); |
@@ -78,2 +78,3 @@ import { DocumentNode, GraphQLFieldResolver } from 'graphql'; | ||
fortuneOptions?: FortuneOptions; | ||
fortuneRecordTypeDefinitions?: FortuneRecordTypeDefinitions; | ||
plugins?: GeniePlugin[] | GeniePlugin; | ||
@@ -93,2 +94,5 @@ } | ||
} | ||
export interface FortuneRecordTypeDefinitions { | ||
[key: string]: {[property: string]: any}; | ||
} | ||
@@ -95,0 +99,0 @@ export interface GeniePlugin { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1098246
97
23058
259