@pothos/core
Advanced tools
Comparing version 0.0.0-preview-20220211214221 to 0.0.0-preview-20220225212244
# Change Log | ||
## 0.0.0-preview-20220211214221 | ||
## 0.0.0-preview-20220225212244 | ||
### Patch Changes | ||
- cf4a2d14: cleanup style and comments | ||
## 3.3.2 | ||
### Patch Changes | ||
- 122dd782: Allow subscribe function to return a promise | ||
## 3.3.1 | ||
### Patch Changes | ||
- 03aecf76: update .npmignore | ||
## 3.3.0 | ||
### Minor Changes | ||
- 4ad5f4ff: Normalize resloveType and isTypeOf behavior to match graphql spec behavir and allow both | ||
to be optional | ||
- 80b24ec1: Add ability to branded objects loaded by relay plugin with typename to reduce need to | ||
isTypeOf checks | ||
## 3.2.0 | ||
### Minor Changes | ||
- 4ad5f4ff: Normalize resolveType and isTypeOf behavior to match graphql spec behavior and allow | ||
both to be optional | ||
### Patch Changes | ||
- 43ca3031: Update dev dependencies | ||
## 3.1.2 | ||
@@ -11,0 +40,0 @@ |
@@ -6,3 +6,3 @@ /* eslint-disable unicorn/prefer-object-from-entries */ | ||
import BuiltinScalarRef from './refs/builtin-scalar.js'; | ||
import { isThenable } from './utils/index.js'; | ||
import { getTypeBrand, isThenable } from './utils/index.js'; | ||
import { assertNever, ImplementableInputObjectRef, typeBrandKey, } from './index.js'; | ||
@@ -365,4 +365,4 @@ export default class BuildCache { | ||
var _a; | ||
if (typeof parent === "object" && parent !== null && typeBrandKey in parent) { | ||
const typeBrand = parent[typeBrandKey]; | ||
const typeBrand = getTypeBrand(parent); | ||
if (typeBrand) { | ||
if (typeof typeBrand === "string") { | ||
@@ -369,0 +369,0 @@ return typeBrand; |
@@ -8,3 +8,3 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
export declare type GeneratorResolver<Type, Item> = null extends Type ? AsyncGenerator<Item | null | undefined, Item | null | undefined> : AsyncGenerator<Item, Item>; | ||
export declare type Subscriber<Parent, Args, Context, Shape> = (parent: Parent, args: Args, context: Context, info: GraphQLResolveInfo) => AsyncIterable<Shape>; | ||
export declare type Subscriber<Parent, Args, Context, Shape> = (parent: Parent, args: Args, context: Context, info: GraphQLResolveInfo) => MaybePromise<AsyncIterable<Shape>>; | ||
export declare type EnumValues<Types extends SchemaTypes> = EnumValueConfigMap<Types> | readonly string[]; | ||
@@ -11,0 +11,0 @@ export declare type EnumValueConfigMap<Types extends SchemaTypes> = Record<string, PothosSchemaTypes.EnumValueConfig<Types>>; |
@@ -12,2 +12,3 @@ import { OutputType, SchemaTypes } from '..'; | ||
export declare function brandWithType<Types extends SchemaTypes>(val: unknown, type: OutputType<Types>): void; | ||
export declare function getTypeBrand(val: unknown): import("..").BaseEnum | (new (...args: any[]) => any) | "String" | "ID" | "Int" | "Float" | "Boolean" | null; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -40,2 +40,8 @@ import { typeBrandKey } from '../index.js'; | ||
} | ||
export function getTypeBrand(val) { | ||
if (typeof val === "object" && val !== null && typeBrandKey in val) { | ||
return val[typeBrandKey]; | ||
} | ||
return null; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -369,4 +369,4 @@ "use strict"; | ||
var _a; | ||
if (typeof parent === 'object' && parent !== null && _1.typeBrandKey in parent) { | ||
const typeBrand = parent[_1.typeBrandKey]; | ||
const typeBrand = (0, utils_1.getTypeBrand)(parent); | ||
if (typeBrand) { | ||
if (typeof typeBrand === 'string') { | ||
@@ -373,0 +373,0 @@ return typeBrand; |
@@ -8,3 +8,3 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
export declare type GeneratorResolver<Type, Item> = null extends Type ? AsyncGenerator<Item | null | undefined, Item | null | undefined> : AsyncGenerator<Item, Item>; | ||
export declare type Subscriber<Parent, Args, Context, Shape> = (parent: Parent, args: Args, context: Context, info: GraphQLResolveInfo) => AsyncIterable<Shape>; | ||
export declare type Subscriber<Parent, Args, Context, Shape> = (parent: Parent, args: Args, context: Context, info: GraphQLResolveInfo) => MaybePromise<AsyncIterable<Shape>>; | ||
export declare type EnumValues<Types extends SchemaTypes> = EnumValueConfigMap<Types> | readonly string[]; | ||
@@ -11,0 +11,0 @@ export declare type EnumValueConfigMap<Types extends SchemaTypes> = Record<string, PothosSchemaTypes.EnumValueConfig<Types>>; |
@@ -12,2 +12,3 @@ import { OutputType, SchemaTypes } from '..'; | ||
export declare function brandWithType<Types extends SchemaTypes>(val: unknown, type: OutputType<Types>): void; | ||
export declare function getTypeBrand(val: unknown): import("..").BaseEnum | (new (...args: any[]) => any) | "String" | "ID" | "Int" | "Float" | "Boolean" | null; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.brandWithType = exports.verifyRef = exports.isThenable = exports.assertArray = exports.assertNever = void 0; | ||
exports.getTypeBrand = exports.brandWithType = exports.verifyRef = exports.isThenable = exports.assertArray = exports.assertNever = void 0; | ||
const __1 = require(".."); | ||
@@ -59,2 +59,9 @@ __exportStar(require("./context-cache"), exports); | ||
exports.brandWithType = brandWithType; | ||
function getTypeBrand(val) { | ||
if (typeof val === 'object' && val !== null && __1.typeBrandKey in val) { | ||
return val[__1.typeBrandKey]; | ||
} | ||
return null; | ||
} | ||
exports.getTypeBrand = getTypeBrand; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@pothos/core", | ||
"version": "0.0.0-preview-20220211214221", | ||
"version": "0.0.0-preview-20220225212244", | ||
"description": "Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript", | ||
@@ -37,3 +37,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@pothos/test-utils": "1.0.1", | ||
"@pothos/test-utils": "1.0.2", | ||
"graphql": "16.3.0", | ||
@@ -40,0 +40,0 @@ "graphql-scalars": "^1.14.1", |
@@ -31,3 +31,3 @@ /* eslint-disable unicorn/prefer-object-from-entries */ | ||
import { PluginMap } from './types'; | ||
import { isThenable } from './utils'; | ||
import { getTypeBrand, isThenable } from './utils'; | ||
import { | ||
@@ -567,5 +567,4 @@ assertNever, | ||
const resolveType: GraphQLTypeResolver<unknown, Types['Context']> = (parent, context, info) => { | ||
if (typeof parent === 'object' && parent !== null && typeBrandKey in parent) { | ||
const typeBrand = (parent as { [typeBrandKey]: OutputType<SchemaTypes> })[typeBrandKey]; | ||
const typeBrand = getTypeBrand(parent); | ||
if (typeBrand) { | ||
if (typeof typeBrand === 'string') { | ||
@@ -572,0 +571,0 @@ return typeBrand; |
@@ -52,2 +52,3 @@ /* eslint-disable @typescript-eslint/no-redeclare */ | ||
> = PothosSchemaTypes.RootFieldBuilder<Types, ParentShape, Kind>; | ||
export const RootFieldBuilder = InternalRootFieldBuilder as new < | ||
@@ -54,0 +55,0 @@ Types extends SchemaTypes, |
@@ -57,3 +57,3 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
info: GraphQLResolveInfo, | ||
) => AsyncIterable<Shape>; | ||
) => MaybePromise<AsyncIterable<Shape>>; | ||
@@ -60,0 +60,0 @@ export type EnumValues<Types extends SchemaTypes> = EnumValueConfigMap<Types> | readonly string[]; |
@@ -7,3 +7,2 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
GraphQLScalarValueParser, | ||
GraphQLTypeResolver, | ||
GraphQLUnionType, | ||
@@ -10,0 +9,0 @@ } from 'graphql'; |
@@ -50,1 +50,9 @@ import { OutputType, SchemaTypes, typeBrandKey } from '..'; | ||
} | ||
export function getTypeBrand(val: unknown) { | ||
if (typeof val === 'object' && val !== null && typeBrandKey in val) { | ||
return (val as { [typeBrandKey]: OutputType<SchemaTypes> })[typeBrandKey]; | ||
} | ||
return null; | ||
} |
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
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
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
12461
896964
420