graphql-compose-modules
Advanced tools
Comparing version 1.2.1 to 1.3.0
import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose'; | ||
import { AstResult, AstDirNode, AstFileNode } from './directoryToAst'; | ||
import { AstRootNode, AstDirNode, AstFileNode } from './directoryToAst'; | ||
export interface AstToSchemaOptions { | ||
@@ -8,4 +8,4 @@ schemaComposer?: SchemaComposer<any>; | ||
} | ||
export declare function astToSchema<TContext = any>(ast: AstResult, opts?: AstToSchemaOptions): SchemaComposer<TContext>; | ||
export declare function astToSchema<TContext = any>(ast: AstRootNode, opts?: AstToSchemaOptions): SchemaComposer<TContext>; | ||
export declare function createFields(sc: SchemaComposer<any>, ast: AstDirNode | AstFileNode | void, parent: ObjectTypeComposer, pathPrefix: string, opts?: AstToSchemaOptions): void; | ||
//# sourceMappingURL=astToSchema.d.ts.map |
@@ -37,8 +37,8 @@ "use strict"; | ||
} | ||
if (ast.query) | ||
populateRoot(sc, 'Query', ast.query, opts); | ||
if (ast.mutation) | ||
populateRoot(sc, 'Mutation', ast.mutation, opts); | ||
if (ast.subscription) | ||
populateRoot(sc, 'Subscription', ast.subscription, opts); | ||
if (ast.children.query) | ||
populateRoot(sc, 'Query', ast.children.query, opts); | ||
if (ast.children.mutation) | ||
populateRoot(sc, 'Mutation', ast.children.mutation, opts); | ||
if (ast.children.subscription) | ||
populateRoot(sc, 'Subscription', ast.children.subscription, opts); | ||
return sc; | ||
@@ -45,0 +45,0 @@ } |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
} | ||
export declare type AstNodeKinds = 'rootType' | 'dir' | 'file'; | ||
export declare type AstNodeKinds = 'rootType' | 'dir' | 'file' | 'root'; | ||
export interface AstBaseNode { | ||
@@ -35,11 +35,14 @@ kind: AstNodeKinds; | ||
} | ||
export interface AstResult { | ||
query?: AstRootTypeNode; | ||
mutation?: AstRootTypeNode; | ||
subscription?: AstRootTypeNode; | ||
declare type RootTypeNames = 'query' | 'mutation' | 'subscription'; | ||
export interface AstRootNode extends AstBaseNode { | ||
kind: 'root'; | ||
children: { | ||
[T in RootTypeNames]?: AstRootTypeNode; | ||
}; | ||
} | ||
export declare const defaultOptions: DirectoryToAstOptions; | ||
export declare function directoryToAst(m: NodeModule, options?: DirectoryToAstOptions): AstResult; | ||
export declare function directoryToAst(m: NodeModule, options?: DirectoryToAstOptions): AstRootNode; | ||
export declare function getAstForDir(m: NodeModule, absPath: string, options?: DirectoryToAstOptions): AstDirNode | void; | ||
export declare function getAstForFile(m: NodeModule, absPath: string, options?: DirectoryToAstOptions): AstFileNode | void; | ||
export {}; | ||
//# sourceMappingURL=directoryToAst.d.ts.map |
@@ -35,3 +35,8 @@ "use strict"; | ||
}); | ||
var result = {}; | ||
var result = { | ||
kind: 'root', | ||
name: path_1.basename(schemaPath), | ||
absPath: schemaPath, | ||
children: {}, | ||
}; | ||
fs_1.default.readdirSync(schemaPath).forEach(function (filename) { | ||
@@ -45,3 +50,3 @@ var absPath = path_1.join(schemaPath, filename); | ||
var opType = found[1].toLowerCase(); | ||
var rootTypeAst = result[opType]; | ||
var rootTypeAst = result.children[opType]; | ||
if (!rootTypeAst) | ||
@@ -66,3 +71,3 @@ rootTypeAst = { | ||
} | ||
result[opType] = rootTypeAst; | ||
result.children[opType] = rootTypeAst; | ||
} | ||
@@ -69,0 +74,0 @@ } |
@@ -8,5 +8,6 @@ /// <reference types="node" /> | ||
export declare function loadSchemaComposer(module: NodeModule, opts: BuildOptions): import("graphql-compose").SchemaComposer<any>; | ||
export { directoryToAst, DirectoryToAstOptions, AstNodeKinds, AstBaseNode, AstRootTypeNode, AstDirNode, AstFileNode, AstResult, } from './directoryToAst'; | ||
export { directoryToAst, DirectoryToAstOptions, AstNodeKinds, AstBaseNode, AstRootTypeNode, AstDirNode, AstFileNode, AstRootNode, } from './directoryToAst'; | ||
export { astToSchema, AstToSchemaOptions } from './astToSchema'; | ||
export * from './testHelpers'; | ||
export { astVisitor, VISITOR_REMOVE_NODE, VISITOR_SKIP_CHILDREN, AstVisitor, VisitInfo, } from './astVisitor'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -24,2 +24,6 @@ "use strict"; | ||
__export(require("./testHelpers")); | ||
var astVisitor_1 = require("./astVisitor"); | ||
exports.astVisitor = astVisitor_1.astVisitor; | ||
exports.VISITOR_REMOVE_NODE = astVisitor_1.VISITOR_REMOVE_NODE; | ||
exports.VISITOR_SKIP_CHILDREN = astVisitor_1.VISITOR_SKIP_CHILDREN; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "graphql-compose-modules", | ||
"license": "MIT", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A toolset for construction GraphQL Schema via file structure", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/graphql-compose/graphql-compose-modules", |
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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58042
23
720