Comparing version 0.9.1 to 0.9.2
# Changelog | ||
### 0.9.2 | ||
- Fixes for conditional nullability check | ||
- Fixes for return type of MaybePromiseDeep | ||
- Docs cleanup | ||
### 0.9.1: | ||
- General deploy/package.json cleanup | ||
### 0.9.0: | ||
##### See #16 for more info | ||
- Major API changes. See #16 for more info | ||
@@ -12,1 +22,3 @@ ### 0.7.0-alpha.1 | ||
### 0.6.2 | ||
Initial release |
@@ -272,2 +272,3 @@ import { | ||
| undefined; | ||
missingResolveType(name: string, location: "union" | "interface"): () => null; | ||
} | ||
@@ -274,0 +275,0 @@ export interface BuildTypes< |
@@ -206,4 +206,3 @@ "use strict"; | ||
if (!resolveType) { | ||
throw new Error("Missing resolveType for the " + name + " interface." + | ||
"Be sure to add one in the definition block for the type"); | ||
resolveType = this.missingResolveType(config.name, "union"); | ||
} | ||
@@ -275,4 +274,3 @@ return new graphql_1.GraphQLInterfaceType({ | ||
if (!resolveType) { | ||
throw new Error("Missing resolveType for the " + config.name + " union." + | ||
"Be sure to add one in the definition block for the type"); | ||
resolveType = this.missingResolveType(config.name, "union"); | ||
} | ||
@@ -512,2 +510,8 @@ return new graphql_1.GraphQLUnionType({ | ||
}; | ||
SchemaBuilder.prototype.missingResolveType = function (name, location) { | ||
console.error(new Error("Missing resolveType for the " + name + " " + location + "." + | ||
"Be sure to add one in the definition block for the type, " + | ||
"or t.resolveType(() => null) if you don't want to implement yet")); | ||
return function () { return null; }; | ||
}; | ||
return SchemaBuilder; | ||
@@ -514,0 +518,0 @@ }()); |
@@ -85,1 +85,7 @@ import { | ||
): NexusObjectTypeDef<TypeName>; | ||
export declare function queryType( | ||
config: NexusObjectTypeConfig<"Query"> | ||
): NexusObjectTypeDef<"Query">; | ||
export declare function mutationType( | ||
config: NexusObjectTypeConfig<"Mutation"> | ||
): NexusObjectTypeDef<"Mutation">; |
@@ -54,2 +54,15 @@ "use strict"; | ||
exports.objectType = objectType; | ||
function queryType(config) { | ||
return objectType(tslib_1.__assign({}, config, { name: "Query" })); | ||
} | ||
exports.queryType = queryType; | ||
function mutationType(config) { | ||
return objectType(tslib_1.__assign({}, config, { name: "Mutation" })); | ||
} | ||
exports.mutationType = mutationType; | ||
// export function subscriptionType( | ||
// config: NexusObjectTypeConfig<"Subscription"> | ||
// ) { | ||
// return objectType({ ...config, name: "Subscription" }); | ||
// } | ||
//# sourceMappingURL=objectType.js.map |
@@ -17,3 +17,3 @@ import { GraphQLScalarTypeConfig } from "graphql"; | ||
/** | ||
* Adds this scalar type as a method on the Object/Interface definition blocks | ||
* Adds this type as a method on the Object/Interface definition blocks | ||
*/ | ||
@@ -20,0 +20,0 @@ asNexusMethod?: string; |
@@ -20,5 +20,10 @@ export { buildTypes, makeSchema } from "./builder"; | ||
export { groupTypes } from "./utils"; | ||
export { FieldResolver } from "./typegenTypeHelpers"; | ||
export { | ||
FieldResolver, | ||
AllInputTypes, | ||
AllOutputTypes, | ||
FieldType, | ||
} from "./typegenTypeHelpers"; | ||
export { core, blocks }; | ||
import * as core from "./core"; | ||
import * as blocks from "./blocks"; |
@@ -6,2 +6,8 @@ import { GraphQLResolveInfo } from "graphql"; | ||
} | ||
export declare type AllInputTypes = GetGen<"allInputTypes">; | ||
export declare type AllOutputTypes = GetGen<"allOutputTypes">; | ||
export declare type FieldType< | ||
TypeName extends string, | ||
FieldName extends string | ||
> = GetGen3<"fieldTypes", TypeName, FieldName>; | ||
export declare type MaybePromise<T> = PromiseLike<T> | T; | ||
@@ -13,9 +19,11 @@ /** | ||
*/ | ||
export declare type MaybePromiseDeep<T> = { | ||
[P in keyof T]?: T[P] extends Array<infer U> | ||
? Array<MaybePromiseDeep<U>> | ||
: T[P] extends ReadonlyArray<infer Y> | ||
? ReadonlyArray<MaybePromiseDeep<Y>> | ||
: MaybePromiseDeep<T[P]> | ||
}; | ||
export declare type MaybePromiseDeep<T> = MaybePromise< | ||
{ | ||
[P in keyof T]?: T[P] extends Array<infer U> | ||
? Array<MaybePromiseDeep<U>> | ||
: T[P] extends ReadonlyArray<infer Y> | ||
? ReadonlyArray<MaybePromiseDeep<Y>> | ||
: MaybePromiseDeep<T[P]> | ||
} | ||
>; | ||
/** | ||
@@ -41,3 +49,3 @@ * The NexusAbstractTypeResolver type can be used if you want to preserve type-safety | ||
info: GraphQLResolveInfo | ||
): MaybePromise<AbstractResolveReturn<TypeName>>; | ||
): MaybePromise<AbstractResolveReturn<TypeName> | null>; | ||
} | ||
@@ -193,6 +201,6 @@ /** | ||
> = HasGen3<"fieldTypes", TypeName, FieldName> extends true | ||
? GetGen3<"fieldTypes", TypeName, FieldName> extends null | ||
? null extends GetGen3<"fieldTypes", TypeName, FieldName> | ||
? false | ||
: HasGen3<"rootTypes", TypeName, FieldName> extends true | ||
? GetGen3<"rootTypes", TypeName, FieldName> extends null | ||
? null extends GetGen3<"rootTypes", TypeName, FieldName> | ||
? true | ||
@@ -199,0 +207,0 @@ : false |
{ | ||
"name": "nexus", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"main": "dist", | ||
@@ -17,2 +17,3 @@ "types": "dist", | ||
"prepublish": "yarn clean && yarn lint && yarn build", | ||
"postpublish": "yarn upgrade-deps", | ||
"website": "cd website && yarn && yarn start", | ||
@@ -19,0 +20,0 @@ "examples": "yarn link-examples && cd website && yarn gulp run-examples", |
@@ -397,6 +397,3 @@ import { | ||
if (!resolveType) { | ||
throw new Error( | ||
`Missing resolveType for the ${name} interface.` + | ||
`Be sure to add one in the definition block for the type` | ||
); | ||
resolveType = this.missingResolveType(config.name, "union"); | ||
} | ||
@@ -469,6 +466,3 @@ return new GraphQLInterfaceType({ | ||
if (!resolveType) { | ||
throw new Error( | ||
`Missing resolveType for the ${config.name} union.` + | ||
`Be sure to add one in the definition block for the type` | ||
); | ||
resolveType = this.missingResolveType(config.name, "union"); | ||
} | ||
@@ -834,2 +828,13 @@ return new GraphQLUnionType({ | ||
} | ||
missingResolveType(name: string, location: "union" | "interface") { | ||
console.error( | ||
new Error( | ||
`Missing resolveType for the ${name} ${location}.` + | ||
`Be sure to add one in the definition block for the type, ` + | ||
`or t.resolveType(() => null) if you don't want to implement yet` | ||
) | ||
); | ||
return () => null; | ||
} | ||
} | ||
@@ -836,0 +841,0 @@ |
@@ -105,1 +105,15 @@ import { | ||
} | ||
export function queryType(config: NexusObjectTypeConfig<"Query">) { | ||
return objectType({ ...config, name: "Query" }); | ||
} | ||
export function mutationType(config: NexusObjectTypeConfig<"Mutation">) { | ||
return objectType({ ...config, name: "Mutation" }); | ||
} | ||
// export function subscriptionType( | ||
// config: NexusObjectTypeConfig<"Subscription"> | ||
// ) { | ||
// return objectType({ ...config, name: "Subscription" }); | ||
// } |
@@ -20,3 +20,3 @@ import { GraphQLScalarTypeConfig, assertValidName } from "graphql"; | ||
/** | ||
* Adds this scalar type as a method on the Object/Interface definition blocks | ||
* Adds this type as a method on the Object/Interface definition blocks | ||
*/ | ||
@@ -23,0 +23,0 @@ asNexusMethod?: string; |
@@ -21,5 +21,10 @@ // All of the Public API definitions | ||
export { groupTypes } from "./utils"; | ||
export { FieldResolver } from "./typegenTypeHelpers"; | ||
export { | ||
FieldResolver, | ||
AllInputTypes, | ||
AllOutputTypes, | ||
FieldType, | ||
} from "./typegenTypeHelpers"; | ||
export { core, blocks }; | ||
import * as core from "./core"; | ||
import * as blocks from "./blocks"; |
@@ -8,2 +8,11 @@ import { GraphQLResolveInfo } from "graphql"; | ||
export type AllInputTypes = GetGen<"allInputTypes">; | ||
export type AllOutputTypes = GetGen<"allOutputTypes">; | ||
export type FieldType< | ||
TypeName extends string, | ||
FieldName extends string | ||
> = GetGen3<"fieldTypes", TypeName, FieldName>; | ||
export type MaybePromise<T> = PromiseLike<T> | T; | ||
@@ -16,9 +25,11 @@ | ||
*/ | ||
export type MaybePromiseDeep<T> = { | ||
[P in keyof T]?: T[P] extends Array<infer U> | ||
? Array<MaybePromiseDeep<U>> | ||
: T[P] extends ReadonlyArray<infer Y> | ||
? ReadonlyArray<MaybePromiseDeep<Y>> | ||
: MaybePromiseDeep<T[P]> | ||
}; | ||
export type MaybePromiseDeep<T> = MaybePromise< | ||
{ | ||
[P in keyof T]?: T[P] extends Array<infer U> | ||
? Array<MaybePromiseDeep<U>> | ||
: T[P] extends ReadonlyArray<infer Y> | ||
? ReadonlyArray<MaybePromiseDeep<Y>> | ||
: MaybePromiseDeep<T[P]> | ||
} | ||
>; | ||
@@ -45,3 +56,3 @@ /** | ||
info: GraphQLResolveInfo | ||
): MaybePromise<AbstractResolveReturn<TypeName>>; | ||
): MaybePromise<AbstractResolveReturn<TypeName> | null>; | ||
} | ||
@@ -206,6 +217,6 @@ | ||
> = HasGen3<"fieldTypes", TypeName, FieldName> extends true | ||
? GetGen3<"fieldTypes", TypeName, FieldName> extends null | ||
? null extends GetGen3<"fieldTypes", TypeName, FieldName> | ||
? false | ||
: HasGen3<"rootTypes", TypeName, FieldName> extends true | ||
? GetGen3<"rootTypes", TypeName, FieldName> extends null | ||
? null extends GetGen3<"rootTypes", TypeName, FieldName> | ||
? true | ||
@@ -212,0 +223,0 @@ : false |
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
510206
7725