graphql-tools
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -5,3 +5,6 @@ # Change log | ||
* ... | ||
### v0.11.0 | ||
* Remove dependency on `graphql-subscription` and use an interface for PubSub [PR #295](https://github.com/apollographql/graphql-tools/pull/295) | ||
* Support schema AST as a type definition input [PR #300](https://github.com/apollographql/graphql-tools/pull/300) | ||
* Update graphql typings to 0.9.0 [PR #298](https://github.com/apollographql/graphql-tools/pull/298) | ||
@@ -8,0 +11,0 @@ ### v0.10.1 |
import { GraphQLSchema } from 'graphql'; | ||
import { PubSub } from 'graphql-subscriptions'; | ||
export declare function autopublishMutationResults(schema: GraphQLSchema, pubsub: PubSub): void; | ||
import { IPubSub } from './Interfaces'; | ||
export declare function autopublishMutationResults(schema: GraphQLSchema, pubsub: IPubSub): void; |
@@ -1,2 +0,2 @@ | ||
import { GraphQLSchema, GraphQLField, ExecutionResult, GraphQLType, GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLTypeResolver, GraphQLScalarType } from 'graphql'; | ||
import { GraphQLSchema, GraphQLField, ExecutionResult, GraphQLType, GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLTypeResolver, GraphQLScalarType, DocumentNode } from 'graphql'; | ||
export interface IResolverValidationOptions { | ||
@@ -12,3 +12,3 @@ requireResolversForArgs?: boolean; | ||
} | ||
export declare type ITypedef = (() => ITypedef[]) | string; | ||
export declare type ITypedef = (() => ITypedef[]) | string | DocumentNode; | ||
export declare type ITypeDefinitions = ITypedef | ITypedef[]; | ||
@@ -56,1 +56,4 @@ export declare type IResolverObject = { | ||
} | ||
export interface IPubSub { | ||
publish(triggerName: string, payload: any): any; | ||
} |
@@ -77,2 +77,5 @@ // Generates a schema for graphql-js given a shorthand schema | ||
exports.makeExecutableSchema = makeExecutableSchema; | ||
function isDocumentNode(typeDefinitions) { | ||
return typeDefinitions.kind !== undefined; | ||
} | ||
function concatenateTypeDefs(typeDefinitionsAry, calledFunctionRefs) { | ||
@@ -82,2 +85,5 @@ if (calledFunctionRefs === void 0) { calledFunctionRefs = []; } | ||
typeDefinitionsAry.forEach(function (typeDef) { | ||
if (isDocumentNode(typeDef)) { | ||
typeDef = graphql_1.print(typeDef); | ||
} | ||
if (typeof typeDef === 'function') { | ||
@@ -103,10 +109,16 @@ if (calledFunctionRefs.indexOf(typeDef) === -1) { | ||
var myDefinitions = typeDefinitions; | ||
if (typeof myDefinitions !== 'string') { | ||
var astDocument; | ||
if (isDocumentNode(typeDefinitions)) { | ||
astDocument = typeDefinitions; | ||
} | ||
else if (typeof myDefinitions !== 'string') { | ||
if (!Array.isArray(myDefinitions)) { | ||
// TODO improve error message and say what type was actually found | ||
throw new SchemaError('`typeDefs` must be a string or array'); | ||
var type = typeof myDefinitions; | ||
throw new SchemaError("typeDefs must be a string, array or schema AST, got " + type); | ||
} | ||
myDefinitions = concatenateTypeDefs(myDefinitions); | ||
} | ||
var astDocument = graphql_1.parse(myDefinitions); | ||
if (typeof myDefinitions === 'string') { | ||
astDocument = graphql_1.parse(myDefinitions); | ||
} | ||
var schema = graphql_2.buildASTSchema(astDocument); | ||
@@ -437,3 +449,3 @@ var extensionsAst = extractExtensionDefinitions(astDocument); | ||
if (typeof property === 'function') { | ||
return source[fieldName](args, context); | ||
return property(args, context); | ||
} | ||
@@ -440,0 +452,0 @@ return property; |
{ | ||
"name": "graphql-tools", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "A set of useful tools for GraphQL", | ||
@@ -58,3 +58,3 @@ "main": "dist/index.js", | ||
"optionalDependencies": { | ||
"@types/graphql": "^0.8.5" | ||
"@types/graphql": "^0.9.0" | ||
}, | ||
@@ -84,4 +84,4 @@ "devDependencies": { | ||
"tslint": "^4.2.0", | ||
"typescript": "2.2.1" | ||
"typescript": "2.2.2" | ||
} | ||
} |
# GraphQL-tools: generate and mock GraphQL.js schemas | ||
[![npm version](https://badge.fury.io/js/graphql-tools.svg)](https://badge.fury.io/js/graphql-tools) | ||
@@ -24,3 +23,3 @@ [![Build Status](https://travis-ci.org/apollographql/graphql-tools.svg?branch=master)](https://travis-ci.org/apollographql/graphql-tools) | ||
type Author { | ||
id: Int! # the ! means that every author object _must_ have an id | ||
id: ID! # the ! means that every author object _must_ have an id | ||
firstName: String | ||
@@ -32,3 +31,3 @@ lastName: String | ||
type Post { | ||
id: Int! | ||
id: ID! | ||
title: String | ||
@@ -47,3 +46,3 @@ author: Author | ||
upvotePost ( | ||
postId: Int! | ||
postId: ID! | ||
): Post | ||
@@ -50,0 +49,0 @@ } |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91345
905
111