Comparing version 0.9.3 to 0.9.4
# Changelog | ||
### 0.9.4 | ||
- Internal: nexusWrappedFn -> nexusWrappedType | ||
### 0.9.3 | ||
@@ -4,0 +8,0 @@ |
@@ -43,2 +43,3 @@ import { | ||
AllNexusNamedTypeDefs, | ||
NexusWrappedType, | ||
} from "./definitions/wrapping"; | ||
@@ -251,3 +252,6 @@ import { | ||
protected getInputType( | ||
name: string | AllNexusInputTypeDefs | ||
name: | ||
| string | ||
| AllNexusInputTypeDefs | ||
| NexusWrappedType<AllNexusInputTypeDefs> | ||
): GraphQLPossibleInputs; | ||
@@ -259,3 +263,6 @@ protected getOutputType(name: string): GraphQLPossibleOutputs; | ||
protected getOrBuildType( | ||
name: string | AllNexusNamedTypeDefs | ||
name: | ||
| string | ||
| AllNexusNamedTypeDefs | ||
| NexusWrappedType<AllNexusNamedTypeDefs> | ||
): GraphQLNamedType; | ||
@@ -262,0 +269,0 @@ protected getResolver( |
@@ -289,2 +289,3 @@ "use strict"; | ||
SchemaBuilder.prototype.missingType = function (typeName) { | ||
invariantGuard(typeName); | ||
var suggestions = utils_1.suggestionList(typeName, Object.keys(this.buildingTypes).concat(Object.keys(this.finalTypeMap))); | ||
@@ -461,3 +462,3 @@ var suggestionsString = ""; | ||
invariantGuard(name); | ||
if (wrapping_1.isNexusNamedTypeDef(name)) { | ||
if (wrapping_1.isNexusNamedTypeDef(name) || wrapping_1.isNexusWrappedType(name)) { | ||
return this.getOrBuildType(name.name); | ||
@@ -537,3 +538,3 @@ } | ||
} | ||
if (wrapping_1.isNexusWrappedFn(types)) { | ||
if (wrapping_1.isNexusWrappedType(types)) { | ||
addTypes(builder, types.fn(builder)); | ||
@@ -540,0 +541,0 @@ return; |
@@ -16,3 +16,3 @@ import { | ||
ExtendObject = "ExtendObject", | ||
WrappedFn = "WrappedFn", | ||
WrappedType = "WrappedType", | ||
OutputField = "OutputField", | ||
@@ -19,0 +19,0 @@ InputField = "InputField", |
@@ -13,3 +13,3 @@ "use strict"; | ||
NexusTypes["ExtendObject"] = "ExtendObject"; | ||
NexusTypes["WrappedFn"] = "WrappedFn"; | ||
NexusTypes["WrappedType"] = "WrappedType"; | ||
NexusTypes["OutputField"] = "OutputField"; | ||
@@ -16,0 +16,0 @@ NexusTypes["InputField"] = "InputField"; |
import { GetGen, GetGen2 } from "../typegenTypeHelpers"; | ||
import { AllNexusInputTypeDefs } from "./wrapping"; | ||
import { AllNexusInputTypeDefs, NexusWrappedType } from "./wrapping"; | ||
export interface CommonArgConfig { | ||
@@ -38,3 +38,6 @@ /** | ||
*/ | ||
type: T | AllNexusInputTypeDefs<T>; | ||
type: | ||
| T | ||
| AllNexusInputTypeDefs<T> | ||
| NexusWrappedType<AllNexusInputTypeDefs<T>>; | ||
/** | ||
@@ -41,0 +44,0 @@ * Configure the default for the object |
@@ -9,3 +9,7 @@ import { | ||
import { NexusArgDef } from "./args"; | ||
import { AllNexusOutputTypeDefs, NexusInputTypeName } from "./wrapping"; | ||
import { | ||
AllNexusOutputTypeDefs, | ||
NexusInputTypeName, | ||
NexusWrappedType, | ||
} from "./wrapping"; | ||
import { BaseScalars } from "./_types"; | ||
@@ -55,3 +59,6 @@ export interface CommonFieldConfig { | ||
> extends OutputScalarConfig<TypeName, FieldName> { | ||
type: GetGen<"allOutputTypes"> | AllNexusOutputTypeDefs; | ||
type: | ||
| GetGen<"allOutputTypes"> | ||
| AllNexusOutputTypeDefs | ||
| NexusWrappedType<AllNexusOutputTypeDefs>; | ||
} | ||
@@ -58,0 +65,0 @@ export declare type NexusOutputFieldDef = NexusOutputFieldConfig< |
@@ -37,10 +37,13 @@ import { GraphQLNamedType } from "graphql"; | ||
| GraphQLNamedType; | ||
export declare type WrappedFnType = (builder: SchemaBuilder) => any; | ||
export declare type WrappedTypeFn<T extends AllNexusNamedTypeDefs> = ( | ||
builder: SchemaBuilder | ||
) => T; | ||
/** | ||
* Container object for a "wrapped function" | ||
*/ | ||
export declare class NexusWrappedFn { | ||
protected wrappedFn: WrappedFnType; | ||
constructor(wrappedFn: WrappedFnType); | ||
readonly fn: WrappedFnType; | ||
export declare class NexusWrappedType<T extends AllNexusNamedTypeDefs> { | ||
readonly name: string; | ||
protected wrappedFn: WrappedTypeFn<T>; | ||
constructor(name: string, wrappedFn: WrappedTypeFn<T>); | ||
readonly fn: WrappedTypeFn<T>; | ||
} | ||
@@ -53,3 +56,6 @@ /** | ||
*/ | ||
export declare function nexusWrappedFn(fn: WrappedFnType): NexusWrappedFn; | ||
export declare function nexusWrappedType<T extends AllNexusNamedTypeDefs>( | ||
name: string, | ||
fn: WrappedTypeFn<T> | ||
): NexusWrappedType<T>; | ||
export declare function isNexusTypeDef( | ||
@@ -66,3 +72,5 @@ obj: any | ||
): obj is NexusExtendTypeDef<string>; | ||
export declare function isNexusWrappedFn(obj: any): obj is NexusWrappedFn; | ||
export declare function isNexusWrappedType( | ||
obj: any | ||
): obj is NexusWrappedType<AllNexusNamedTypeDefs>; | ||
export declare function isNexusEnumTypeDef( | ||
@@ -69,0 +77,0 @@ obj: any |
@@ -7,7 +7,8 @@ "use strict"; | ||
*/ | ||
var NexusWrappedFn = /** @class */ (function () { | ||
function NexusWrappedFn(wrappedFn) { | ||
var NexusWrappedType = /** @class */ (function () { | ||
function NexusWrappedType(name, wrappedFn) { | ||
this.name = name; | ||
this.wrappedFn = wrappedFn; | ||
} | ||
Object.defineProperty(NexusWrappedFn.prototype, "fn", { | ||
Object.defineProperty(NexusWrappedType.prototype, "fn", { | ||
get: function () { | ||
@@ -19,6 +20,6 @@ return this.wrappedFn; | ||
}); | ||
return NexusWrappedFn; | ||
return NexusWrappedType; | ||
}()); | ||
exports.NexusWrappedFn = NexusWrappedFn; | ||
_types_1.withNexusSymbol(NexusWrappedFn, _types_1.NexusTypes.WrappedFn); | ||
exports.NexusWrappedType = NexusWrappedType; | ||
_types_1.withNexusSymbol(NexusWrappedType, _types_1.NexusTypes.WrappedType); | ||
/** | ||
@@ -30,6 +31,6 @@ * Useful primarily for plugins, where you want to delay the execution | ||
*/ | ||
function nexusWrappedFn(fn) { | ||
return new NexusWrappedFn(fn); | ||
function nexusWrappedType(name, fn) { | ||
return new NexusWrappedType(name, fn); | ||
} | ||
exports.nexusWrappedFn = nexusWrappedFn; | ||
exports.nexusWrappedType = nexusWrappedType; | ||
var NamedTypeDefs = new Set([ | ||
@@ -55,6 +56,6 @@ _types_1.NexusTypes.Enum, | ||
exports.isNexusExtendTypeDef = isNexusExtendTypeDef; | ||
function isNexusWrappedFn(obj) { | ||
return (isNexusTypeDef(obj) && obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.WrappedFn); | ||
function isNexusWrappedType(obj) { | ||
return (isNexusTypeDef(obj) && obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.WrappedType); | ||
} | ||
exports.isNexusWrappedFn = isNexusWrappedFn; | ||
exports.isNexusWrappedType = isNexusWrappedType; | ||
function isNexusEnumTypeDef(obj) { | ||
@@ -61,0 +62,0 @@ return isNexusTypeDef(obj) && obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.Enum; |
@@ -17,3 +17,3 @@ export { buildTypes, makeSchema } from "./builder"; | ||
export { unionType } from "./definitions/unionType"; | ||
export { nexusWrappedFn } from "./definitions/wrapping"; | ||
export { nexusWrappedType } from "./definitions/wrapping"; | ||
export { convertSDL } from "./sdlConverter"; | ||
@@ -20,0 +20,0 @@ export { groupTypes } from "./utils"; |
@@ -30,3 +30,3 @@ "use strict"; | ||
var wrapping_1 = require("./definitions/wrapping"); | ||
exports.nexusWrappedFn = wrapping_1.nexusWrappedFn; | ||
exports.nexusWrappedType = wrapping_1.nexusWrappedType; | ||
var sdlConverter_1 = require("./sdlConverter"); | ||
@@ -33,0 +33,0 @@ exports.convertSDL = sdlConverter_1.convertSDL; |
@@ -28,4 +28,4 @@ import { | ||
export declare function suggestionList( | ||
input: string, | ||
options: string[] | ||
input?: string, | ||
options?: string[] | ||
): string[]; | ||
@@ -32,0 +32,0 @@ export declare function objValues<T>(obj: Record<string, T>): T[]; |
@@ -28,2 +28,4 @@ "use strict"; | ||
function suggestionList(input, options) { | ||
if (input === void 0) { input = ""; } | ||
if (options === void 0) { options = []; } | ||
var optionsByDistance = Object.create(null); | ||
@@ -30,0 +32,0 @@ var oLength = options.length; |
{ | ||
"name": "nexus", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"main": "dist", | ||
@@ -5,0 +5,0 @@ "types": "dist", |
@@ -77,3 +77,4 @@ import { | ||
isNexusUnionTypeDef, | ||
isNexusWrappedFn, | ||
isNexusWrappedType, | ||
NexusWrappedType, | ||
} from "./definitions/wrapping"; | ||
@@ -486,2 +487,3 @@ import { | ||
protected missingType(typeName: string): GraphQLNamedType { | ||
invariantGuard(typeName); | ||
const suggestions = suggestionList( | ||
@@ -733,3 +735,6 @@ typeName, | ||
protected getInputType( | ||
name: string | AllNexusInputTypeDefs | ||
name: | ||
| string | ||
| AllNexusInputTypeDefs | ||
| NexusWrappedType<AllNexusInputTypeDefs> | ||
): GraphQLPossibleInputs { | ||
@@ -775,6 +780,9 @@ const type = this.getOrBuildType(name); | ||
protected getOrBuildType( | ||
name: string | AllNexusNamedTypeDefs | ||
name: | ||
| string | ||
| AllNexusNamedTypeDefs | ||
| NexusWrappedType<AllNexusNamedTypeDefs> | ||
): GraphQLNamedType { | ||
invariantGuard(name); | ||
if (isNexusNamedTypeDef(name)) { | ||
if (isNexusNamedTypeDef(name) || isNexusWrappedType(name)) { | ||
return this.getOrBuildType(name.name); | ||
@@ -875,3 +883,3 @@ } | ||
} | ||
if (isNexusWrappedFn(types)) { | ||
if (isNexusWrappedType(types)) { | ||
addTypes(builder, types.fn(builder)); | ||
@@ -878,0 +886,0 @@ return; |
@@ -18,3 +18,3 @@ import { | ||
ExtendObject = "ExtendObject", | ||
WrappedFn = "WrappedFn", | ||
WrappedType = "WrappedType", | ||
OutputField = "OutputField", | ||
@@ -21,0 +21,0 @@ InputField = "InputField", |
import { GetGen, GetGen2 } from "../typegenTypeHelpers"; | ||
import { AllNexusInputTypeDefs } from "./wrapping"; | ||
import { AllNexusInputTypeDefs, NexusWrappedType } from "./wrapping"; | ||
import { NexusTypes, withNexusSymbol } from "./_types"; | ||
@@ -42,3 +42,6 @@ | ||
*/ | ||
type: T | AllNexusInputTypeDefs<T>; | ||
type: | ||
| T | ||
| AllNexusInputTypeDefs<T> | ||
| NexusWrappedType<AllNexusInputTypeDefs<T>>; | ||
/** | ||
@@ -45,0 +48,0 @@ * Configure the default for the object |
@@ -9,3 +9,7 @@ import { | ||
import { NexusArgDef } from "./args"; | ||
import { AllNexusOutputTypeDefs, NexusInputTypeName } from "./wrapping"; | ||
import { | ||
AllNexusOutputTypeDefs, | ||
NexusInputTypeName, | ||
NexusWrappedType, | ||
} from "./wrapping"; | ||
import { BaseScalars } from "./_types"; | ||
@@ -58,3 +62,6 @@ | ||
> extends OutputScalarConfig<TypeName, FieldName> { | ||
type: GetGen<"allOutputTypes"> | AllNexusOutputTypeDefs; | ||
type: | ||
| GetGen<"allOutputTypes"> | ||
| AllNexusOutputTypeDefs | ||
| NexusWrappedType<AllNexusOutputTypeDefs>; | ||
} | ||
@@ -61,0 +68,0 @@ |
@@ -41,3 +41,5 @@ import { GraphQLNamedType } from "graphql"; | ||
export type WrappedFnType = (builder: SchemaBuilder) => any; | ||
export type WrappedTypeFn<T extends AllNexusNamedTypeDefs> = ( | ||
builder: SchemaBuilder | ||
) => T; | ||
@@ -47,5 +49,5 @@ /** | ||
*/ | ||
export class NexusWrappedFn { | ||
constructor(protected wrappedFn: WrappedFnType) {} | ||
get fn(): WrappedFnType { | ||
export class NexusWrappedType<T extends AllNexusNamedTypeDefs> { | ||
constructor(readonly name: string, protected wrappedFn: WrappedTypeFn<T>) {} | ||
get fn(): WrappedTypeFn<T> { | ||
return this.wrappedFn; | ||
@@ -55,3 +57,3 @@ } | ||
withNexusSymbol(NexusWrappedFn, NexusTypes.WrappedFn); | ||
withNexusSymbol(NexusWrappedType, NexusTypes.WrappedType); | ||
@@ -64,4 +66,7 @@ /** | ||
*/ | ||
export function nexusWrappedFn(fn: WrappedFnType) { | ||
return new NexusWrappedFn(fn); | ||
export function nexusWrappedType<T extends AllNexusNamedTypeDefs>( | ||
name: string, | ||
fn: WrappedTypeFn<T> | ||
) { | ||
return new NexusWrappedType(name, fn); | ||
} | ||
@@ -93,5 +98,7 @@ | ||
} | ||
export function isNexusWrappedFn(obj: any): obj is NexusWrappedFn { | ||
export function isNexusWrappedType( | ||
obj: any | ||
): obj is NexusWrappedType<AllNexusNamedTypeDefs> { | ||
return ( | ||
isNexusTypeDef(obj) && obj[NexusWrappedSymbol] === NexusTypes.WrappedFn | ||
isNexusTypeDef(obj) && obj[NexusWrappedSymbol] === NexusTypes.WrappedType | ||
); | ||
@@ -98,0 +105,0 @@ } |
@@ -18,3 +18,3 @@ // All of the Public API definitions | ||
export { unionType } from "./definitions/unionType"; | ||
export { nexusWrappedFn } from "./definitions/wrapping"; | ||
export { nexusWrappedType } from "./definitions/wrapping"; | ||
export { convertSDL } from "./sdlConverter"; | ||
@@ -21,0 +21,0 @@ export { groupTypes } from "./utils"; |
@@ -47,3 +47,6 @@ import { | ||
*/ | ||
export function suggestionList(input: string, options: string[]): string[] { | ||
export function suggestionList( | ||
input: string = "", | ||
options: string[] = [] | ||
): string[] { | ||
var optionsByDistance = Object.create(null); | ||
@@ -50,0 +53,0 @@ var oLength = options.length; |
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
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
521933
7996