Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pothos/core

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pothos/core - npm Package Compare versions

Comparing version 3.1.2 to 3.2.0

11

CHANGELOG.md
# Change Log
## 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

@@ -4,0 +15,0 @@

44

esm/build-cache.js
/* eslint-disable unicorn/prefer-object-from-entries */
import { defaultFieldResolver, GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLString, GraphQLUnionType, } from 'graphql';
import { defaultFieldResolver, defaultTypeResolver, GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLString, GraphQLUnionType, } from 'graphql';
import SchemaBuilder from './builder.js';

@@ -342,3 +342,4 @@ import { MergedPlugins } from './plugins/index.js';

}
buildObject({ isTypeOf, ...config }) {
buildObject(config) {
var _a;
const type = new GraphQLObjectType({

@@ -352,2 +353,5 @@ ...config,

fields: () => this.getFields(type),
isTypeOf: config.kind === "Object"
? this.plugin.wrapIsTypeOf((_a = config.isTypeOf) !== null && _a !== void 0 ? _a : undefined, config)
: undefined,
interfaces: config.kind === "Object"

@@ -361,2 +365,3 @@ ? () => config.interfaces.map((iface) => this.getTypeOfKind(iface, "Interface"))

const resolveType = (parent, context, info) => {
var _a;
if (typeof parent === "object" && parent !== null && typeBrandKey in parent) {

@@ -369,21 +374,4 @@ const typeBrand = parent[typeBrandKey];

}
const implementers = this.getImplementers(type);
const promises = [];
for (const impl of implementers) {
if (!impl.isTypeOf) {
// eslint-disable-next-line no-continue
continue;
}
const result = impl.isTypeOf(parent, context, info);
if (isThenable(result)) {
promises.push(result.then((res) => (res ? impl : null)));
}
else if (result) {
return impl.name;
}
}
if (promises.length > 0) {
return Promise.all(promises).then((results) => { var _a; return (_a = results.find((result) => !!result)) === null || _a === void 0 ? void 0 : _a.name; });
}
return undefined;
const resolver = (_a = config.resolveType) !== null && _a !== void 0 ? _a : defaultTypeResolver;
return resolver(parent, context, info, type);
};

@@ -404,4 +392,14 @@ const type = new GraphQLInterfaceType({

buildUnion(config) {
const resolveType = (...args) => {
const resultOrPromise = config.resolveType(...args);
const resolveType = (parent, context, info, type) => {
if (typeof parent === "object" && parent !== null && typeBrandKey in parent) {
const typeBrand = parent[typeBrandKey];
if (typeof typeBrand === "string") {
return typeBrand;
}
return this.getTypeConfig(typeBrand).name;
}
if (!config.resolveType) {
return defaultTypeResolver(parent, context, info, type);
}
const resultOrPromise = config.resolveType(parent, context, info, type);
const getResult = (result) => {

@@ -408,0 +406,0 @@ if (typeof result === "string" || !result) {

@@ -1,5 +0,5 @@

import { GraphQLFieldResolver, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { PothosEnumValueConfig, PothosInterfaceTypeConfig, PothosUnionTypeConfig } from '../types';
import { BasePlugin } from './plugin';
import { BuildCache, PothosInputFieldConfig, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes } from '..';
import { BuildCache, PothosInputFieldConfig, PothosObjectTypeConfig, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes } from '..';
export declare class MergedPlugins<Types extends SchemaTypes> extends BasePlugin<Types> {

@@ -17,3 +17,4 @@ plugins: BasePlugin<Types, object>[];

wrapResolveType(resolveType: GraphQLTypeResolver<unknown, Types['Context']>, typeConfig: PothosInterfaceTypeConfig | PothosUnionTypeConfig): GraphQLTypeResolver<unknown, Types["Context"]>;
wrapIsTypeOf(isTypeOf: GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined, typeConfig: PothosObjectTypeConfig): GraphQLIsTypeOfFn<unknown, Types["Context"]> | undefined;
}
//# sourceMappingURL=merge-plugins.d.ts.map

@@ -36,3 +36,6 @@ import { BasePlugin } from './plugin.js';

}
wrapIsTypeOf(isTypeOf, typeConfig) {
return this.plugins.reduceRight((nextResolveType, plugin) => plugin.wrapIsTypeOf(nextResolveType, typeConfig), isTypeOf);
}
}
//# sourceMappingURL=merge-plugins.js.map

@@ -1,4 +0,4 @@

import { GraphQLFieldResolver, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { PothosEnumValueConfig, PothosInputFieldConfig, PothosInterfaceTypeConfig, PothosOutputFieldConfig, PothosTypeConfig, PothosUnionTypeConfig, SchemaTypes } from '../types';
import { BuildCache } from '..';
import { BuildCache, PothosObjectTypeConfig } from '..';
export declare class BasePlugin<Types extends SchemaTypes, T extends object = object> {

@@ -66,2 +66,9 @@ name: never;

wrapResolveType(resolveType: GraphQLTypeResolver<unknown, Types['Context']>, typeConfig: PothosInterfaceTypeConfig | PothosUnionTypeConfig): GraphQLTypeResolver<unknown, Types['Context']>;
/**
* Called with the isTypeOf for each Object type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosObjectTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapIsTypeOf(isTypeOf: GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined, typeConfig: PothosObjectTypeConfig): GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined;
protected runUnique<R>(key: unknown, cb: () => R): R;

@@ -68,0 +75,0 @@ /**

@@ -82,2 +82,11 @@ import { createContextCache } from '../index.js';

}
/**
* Called with the isTypeOf for each Object type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosObjectTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapIsTypeOf(isTypeOf, typeConfig) {
return isTypeOf;
}
runUnique(key, cb) {

@@ -84,0 +93,0 @@ if (!runCache.has(this.builder)) {

@@ -1,2 +0,2 @@

import { GraphQLResolveInfo, GraphQLScalarLiteralParser, GraphQLScalarValueParser } from 'graphql';
import { GraphQLIsTypeOfFn, GraphQLResolveInfo, GraphQLScalarLiteralParser, GraphQLScalarValueParser, GraphQLUnionType } from 'graphql';
import { EnumValues, InputFieldMap, InterfaceFieldsShape, InterfaceParam, MutationFieldsShape, ObjectFieldsShape, ObjectParam, ParentShape, QueryFieldsShape, RootName, SchemaTypes, SubscriptionFieldsShape, ValidateInterfaces } from '../..';

@@ -16,7 +16,6 @@ import { MaybePromise } from '../utils';

interfaces?: undefined;
isTypeOf?: undefined;
isTypeOf?: GraphQLIsTypeOfFn<unknown, Types['Context']>;
}
interface ObjectTypeWithInterfaceOptions<Types extends SchemaTypes = SchemaTypes, Shape = unknown, Interfaces extends InterfaceParam<Types>[] = InterfaceParam<Types>[]> extends Omit<ObjectTypeOptions<Types, Shape>, 'interfaces' | 'isTypeOf'> {
interface ObjectTypeWithInterfaceOptions<Types extends SchemaTypes = SchemaTypes, Shape = unknown, Interfaces extends InterfaceParam<Types>[] = InterfaceParam<Types>[]> extends Omit<ObjectTypeOptions<Types, Shape>, 'interfaces'> {
interfaces: Interfaces & ValidateInterfaces<Shape, Types, Interfaces[number]>[];
isTypeOf: (obj: ParentShape<Types, Interfaces[number]>, context: Types['Context'], info: GraphQLResolveInfo) => boolean;
}

@@ -40,6 +39,7 @@ interface RootTypeOptions<Types extends SchemaTypes, Type extends RootName> extends BaseTypeOptions<Types> {

interfaces?: Interfaces & ValidateInterfaces<Shape, Types, Interfaces[number]>[];
resolveType?: (parent: Shape, context: Types['Context'], info: GraphQLResolveInfo, type: GraphQLUnionType) => MaybePromise<ObjectParam<Types> | string | null | undefined>;
}
interface UnionTypeOptions<Types extends SchemaTypes = SchemaTypes, Member extends ObjectParam<Types> = ObjectParam<Types>> extends BaseTypeOptions<Types> {
types: Member[];
resolveType: (parent: ParentShape<Types, Member>, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise<Member | null | undefined>;
resolveType?: (parent: ParentShape<Types, Member>, context: Types['Context'], info: GraphQLResolveInfo, type: GraphQLUnionType) => MaybePromise<Member | string | null | undefined>;
}

@@ -46,0 +46,0 @@ interface ScalarTypeOptions<Types extends SchemaTypes = SchemaTypes, ScalarInputShape = unknown, ScalarOutputShape = unknown> extends BaseTypeOptions<Types> {

@@ -347,3 +347,4 @@ "use strict";

}
buildObject({ isTypeOf, ...config }) {
buildObject(config) {
var _a;
const type = new graphql_1.GraphQLObjectType({

@@ -357,2 +358,5 @@ ...config,

fields: () => this.getFields(type),
isTypeOf: config.kind === 'Object'
? this.plugin.wrapIsTypeOf((_a = config.isTypeOf) !== null && _a !== void 0 ? _a : undefined, config)
: undefined,
interfaces: config.kind === 'Object'

@@ -366,2 +370,3 @@ ? () => config.interfaces.map((iface) => this.getTypeOfKind(iface, 'Interface'))

const resolveType = (parent, context, info) => {
var _a;
if (typeof parent === 'object' && parent !== null && _1.typeBrandKey in parent) {

@@ -374,21 +379,4 @@ const typeBrand = parent[_1.typeBrandKey];

}
const implementers = this.getImplementers(type);
const promises = [];
for (const impl of implementers) {
if (!impl.isTypeOf) {
// eslint-disable-next-line no-continue
continue;
}
const result = impl.isTypeOf(parent, context, info);
if ((0, utils_1.isThenable)(result)) {
promises.push(result.then((res) => (res ? impl : null)));
}
else if (result) {
return impl.name;
}
}
if (promises.length > 0) {
return Promise.all(promises).then((results) => { var _a; return (_a = results.find((result) => !!result)) === null || _a === void 0 ? void 0 : _a.name; });
}
return undefined;
const resolver = (_a = config.resolveType) !== null && _a !== void 0 ? _a : graphql_1.defaultTypeResolver;
return resolver(parent, context, info, type);
};

@@ -409,4 +397,14 @@ const type = new graphql_1.GraphQLInterfaceType({

buildUnion(config) {
const resolveType = (...args) => {
const resultOrPromise = config.resolveType(...args);
const resolveType = (parent, context, info, type) => {
if (typeof parent === 'object' && parent !== null && _1.typeBrandKey in parent) {
const typeBrand = parent[_1.typeBrandKey];
if (typeof typeBrand === 'string') {
return typeBrand;
}
return this.getTypeConfig(typeBrand).name;
}
if (!config.resolveType) {
return (0, graphql_1.defaultTypeResolver)(parent, context, info, type);
}
const resultOrPromise = config.resolveType(parent, context, info, type);
const getResult = (result) => {

@@ -413,0 +411,0 @@ if (typeof result === 'string' || !result) {

@@ -1,5 +0,5 @@

import { GraphQLFieldResolver, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { PothosEnumValueConfig, PothosInterfaceTypeConfig, PothosUnionTypeConfig } from '../types';
import { BasePlugin } from './plugin';
import { BuildCache, PothosInputFieldConfig, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes } from '..';
import { BuildCache, PothosInputFieldConfig, PothosObjectTypeConfig, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes } from '..';
export declare class MergedPlugins<Types extends SchemaTypes> extends BasePlugin<Types> {

@@ -17,3 +17,4 @@ plugins: BasePlugin<Types, object>[];

wrapResolveType(resolveType: GraphQLTypeResolver<unknown, Types['Context']>, typeConfig: PothosInterfaceTypeConfig | PothosUnionTypeConfig): GraphQLTypeResolver<unknown, Types["Context"]>;
wrapIsTypeOf(isTypeOf: GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined, typeConfig: PothosObjectTypeConfig): GraphQLIsTypeOfFn<unknown, Types["Context"]> | undefined;
}
//# sourceMappingURL=merge-plugins.d.ts.map

@@ -39,4 +39,7 @@ "use strict";

}
wrapIsTypeOf(isTypeOf, typeConfig) {
return this.plugins.reduceRight((nextResolveType, plugin) => plugin.wrapIsTypeOf(nextResolveType, typeConfig), isTypeOf);
}
}
exports.MergedPlugins = MergedPlugins;
//# sourceMappingURL=merge-plugins.js.map

@@ -1,4 +0,4 @@

import { GraphQLFieldResolver, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { GraphQLFieldResolver, GraphQLIsTypeOfFn, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import { PothosEnumValueConfig, PothosInputFieldConfig, PothosInterfaceTypeConfig, PothosOutputFieldConfig, PothosTypeConfig, PothosUnionTypeConfig, SchemaTypes } from '../types';
import { BuildCache } from '..';
import { BuildCache, PothosObjectTypeConfig } from '..';
export declare class BasePlugin<Types extends SchemaTypes, T extends object = object> {

@@ -66,2 +66,9 @@ name: never;

wrapResolveType(resolveType: GraphQLTypeResolver<unknown, Types['Context']>, typeConfig: PothosInterfaceTypeConfig | PothosUnionTypeConfig): GraphQLTypeResolver<unknown, Types['Context']>;
/**
* Called with the isTypeOf for each Object type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosObjectTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapIsTypeOf(isTypeOf: GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined, typeConfig: PothosObjectTypeConfig): GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined;
protected runUnique<R>(key: unknown, cb: () => R): R;

@@ -68,0 +75,0 @@ /**

@@ -85,2 +85,11 @@ "use strict";

}
/**
* Called with the isTypeOf for each Object type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosObjectTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapIsTypeOf(isTypeOf, typeConfig) {
return isTypeOf;
}
runUnique(key, cb) {

@@ -87,0 +96,0 @@ if (!runCache.has(this.builder)) {

@@ -1,2 +0,2 @@

import { GraphQLResolveInfo, GraphQLScalarLiteralParser, GraphQLScalarValueParser } from 'graphql';
import { GraphQLIsTypeOfFn, GraphQLResolveInfo, GraphQLScalarLiteralParser, GraphQLScalarValueParser, GraphQLUnionType } from 'graphql';
import { EnumValues, InputFieldMap, InterfaceFieldsShape, InterfaceParam, MutationFieldsShape, ObjectFieldsShape, ObjectParam, ParentShape, QueryFieldsShape, RootName, SchemaTypes, SubscriptionFieldsShape, ValidateInterfaces } from '../..';

@@ -16,7 +16,6 @@ import { MaybePromise } from '../utils';

interfaces?: undefined;
isTypeOf?: undefined;
isTypeOf?: GraphQLIsTypeOfFn<unknown, Types['Context']>;
}
interface ObjectTypeWithInterfaceOptions<Types extends SchemaTypes = SchemaTypes, Shape = unknown, Interfaces extends InterfaceParam<Types>[] = InterfaceParam<Types>[]> extends Omit<ObjectTypeOptions<Types, Shape>, 'interfaces' | 'isTypeOf'> {
interface ObjectTypeWithInterfaceOptions<Types extends SchemaTypes = SchemaTypes, Shape = unknown, Interfaces extends InterfaceParam<Types>[] = InterfaceParam<Types>[]> extends Omit<ObjectTypeOptions<Types, Shape>, 'interfaces'> {
interfaces: Interfaces & ValidateInterfaces<Shape, Types, Interfaces[number]>[];
isTypeOf: (obj: ParentShape<Types, Interfaces[number]>, context: Types['Context'], info: GraphQLResolveInfo) => boolean;
}

@@ -40,6 +39,7 @@ interface RootTypeOptions<Types extends SchemaTypes, Type extends RootName> extends BaseTypeOptions<Types> {

interfaces?: Interfaces & ValidateInterfaces<Shape, Types, Interfaces[number]>[];
resolveType?: (parent: Shape, context: Types['Context'], info: GraphQLResolveInfo, type: GraphQLUnionType) => MaybePromise<ObjectParam<Types> | string | null | undefined>;
}
interface UnionTypeOptions<Types extends SchemaTypes = SchemaTypes, Member extends ObjectParam<Types> = ObjectParam<Types>> extends BaseTypeOptions<Types> {
types: Member[];
resolveType: (parent: ParentShape<Types, Member>, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise<Member | null | undefined>;
resolveType?: (parent: ParentShape<Types, Member>, context: Types['Context'], info: GraphQLResolveInfo, type: GraphQLUnionType) => MaybePromise<Member | string | null | undefined>;
}

@@ -46,0 +46,0 @@ interface ScalarTypeOptions<Types extends SchemaTypes = SchemaTypes, ScalarInputShape = unknown, ScalarOutputShape = unknown> extends BaseTypeOptions<Types> {

{
"name": "@pothos/core",
"version": "3.1.2",
"version": "3.2.0",
"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.0",
"@pothos/test-utils": "1.0.1",
"graphql": "16.3.0",

@@ -40,0 +40,0 @@ "graphql-scalars": "^1.14.1",

/* eslint-disable unicorn/prefer-object-from-entries */
import {
defaultFieldResolver,
defaultTypeResolver,
GraphQLBoolean,

@@ -535,10 +536,9 @@ GraphQLEnumType,

private buildObject({
isTypeOf,
...config
}:
| PothosMutationTypeConfig
| PothosObjectTypeConfig
| PothosQueryTypeConfig
| PothosSubscriptionTypeConfig) {
private buildObject(
config:
| PothosMutationTypeConfig
| PothosObjectTypeConfig
| PothosQueryTypeConfig
| PothosSubscriptionTypeConfig,
) {
const type: GraphQLObjectType = new GraphQLObjectType({

@@ -552,8 +552,9 @@ ...config,

fields: () => this.getFields(type),
isTypeOf:
config.kind === 'Object'
? this.plugin.wrapIsTypeOf(config.isTypeOf ?? undefined, config)
: undefined,
interfaces:
config.kind === 'Object'
? () =>
(config as PothosObjectTypeConfig).interfaces.map((iface) =>
this.getTypeOfKind(iface, 'Interface'),
)
? () => config.interfaces.map((iface) => this.getTypeOfKind(iface, 'Interface'))
: undefined,

@@ -577,26 +578,5 @@ });

const implementers = this.getImplementers(type);
const resolver = config.resolveType ?? defaultTypeResolver;
const promises: Promise<PothosObjectTypeConfig | null>[] = [];
for (const impl of implementers) {
if (!impl.isTypeOf) {
// eslint-disable-next-line no-continue
continue;
}
const result = impl.isTypeOf(parent, context, info);
if (isThenable(result)) {
promises.push(result.then((res) => (res ? impl : null)));
} else if (result) {
return impl.name;
}
}
if (promises.length > 0) {
return Promise.all(promises).then((results) => results.find((result) => !!result)?.name);
}
return undefined;
return resolver(parent, context, info, type);
};

@@ -620,5 +600,24 @@

private buildUnion(config: PothosUnionTypeConfig) {
const resolveType: GraphQLTypeResolver<unknown, Types['Context']> = (...args) => {
const resultOrPromise = config.resolveType!(...args);
const resolveType: GraphQLTypeResolver<unknown, Types['Context']> = (
parent,
context,
info,
type,
) => {
if (typeof parent === 'object' && parent !== null && typeBrandKey in parent) {
const typeBrand = (parent as { [typeBrandKey]: OutputType<SchemaTypes> })[typeBrandKey];
if (typeof typeBrand === 'string') {
return typeBrand;
}
return this.getTypeConfig(typeBrand).name;
}
if (!config.resolveType) {
return defaultTypeResolver(parent, context, info, type);
}
const resultOrPromise = config.resolveType(parent, context, info, type);
const getResult = (

@@ -625,0 +624,0 @@ result: GraphQLObjectType<unknown, object> | string | null | undefined,

@@ -7,3 +7,2 @@ import {

GraphQLInt,
GraphQLIsTypeOfFn,
GraphQLObjectType,

@@ -153,3 +152,3 @@ GraphQLScalarSerializer,

extensions: options.extensions,
isTypeOf: options.isTypeOf as GraphQLIsTypeOfFn<unknown, Types['Context']>,
isTypeOf: options.isTypeOf,
pothosOptions: options as PothosSchemaTypes.ObjectTypeOptions,

@@ -156,0 +155,0 @@ };

@@ -1,2 +0,7 @@

import { GraphQLFieldResolver, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import {
GraphQLFieldResolver,
GraphQLIsTypeOfFn,
GraphQLSchema,
GraphQLTypeResolver,
} from 'graphql';
import { PothosEnumValueConfig, PothosInterfaceTypeConfig, PothosUnionTypeConfig } from '../types';

@@ -8,2 +13,3 @@ import { BasePlugin } from './plugin';

PothosInputFieldConfig,
PothosObjectTypeConfig,
PothosOutputFieldConfig,

@@ -90,2 +96,12 @@ PothosTypeConfig,

}
override wrapIsTypeOf(
isTypeOf: GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined,
typeConfig: PothosObjectTypeConfig,
) {
return this.plugins.reduceRight(
(nextResolveType, plugin) => plugin.wrapIsTypeOf(nextResolveType, typeConfig),
isTypeOf,
);
}
}

@@ -1,3 +0,8 @@

import { GraphQLFieldResolver, GraphQLSchema, GraphQLTypeResolver } from 'graphql';
import {
GraphQLFieldResolver,
GraphQLIsTypeOfFn,
GraphQLSchema,
GraphQLTypeResolver,
} from 'graphql';
import {
PothosEnumValueConfig,

@@ -12,3 +17,3 @@ PothosInputFieldConfig,

import { BuildCache, createContextCache } from '..';
import { BuildCache, createContextCache, PothosObjectTypeConfig } from '..';

@@ -131,2 +136,15 @@ const runCache = new WeakMap<{}, Map<unknown, unknown>>();

/**
* Called with the isTypeOf for each Object type
* @param {GraphQLTypeResolver} resolveType - the resolveType function
* @param {PothosObjectTypeConfig} typeConfig - the config object for the Interface or Union type
* @return {GraphQLTypeResolver} - Either the original, or a new resolveType function to use for this field
*/
wrapIsTypeOf(
isTypeOf: GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined,
typeConfig: PothosObjectTypeConfig,
): GraphQLIsTypeOfFn<unknown, Types['Context']> | undefined {
return isTypeOf;
}
protected runUnique<R>(key: unknown, cb: () => R): R {

@@ -133,0 +151,0 @@ if (!runCache.has(this.builder)) {

/* eslint-disable @typescript-eslint/no-unused-vars */
import {
GraphQLIsTypeOfFn,
GraphQLResolveInfo,
GraphQLScalarLiteralParser,
GraphQLScalarSerializer,
GraphQLScalarValueParser,
GraphQLTypeResolver,
GraphQLUnionType,
} from 'graphql';

@@ -42,3 +44,3 @@ import {

interfaces?: undefined;
isTypeOf?: undefined;
isTypeOf?: GraphQLIsTypeOfFn<unknown, Types['Context']>;
}

@@ -50,9 +52,4 @@

Interfaces extends InterfaceParam<Types>[] = InterfaceParam<Types>[],
> extends Omit<ObjectTypeOptions<Types, Shape>, 'interfaces' | 'isTypeOf'> {
> extends Omit<ObjectTypeOptions<Types, Shape>, 'interfaces'> {
interfaces: Interfaces & ValidateInterfaces<Shape, Types, Interfaces[number]>[];
isTypeOf: (
obj: ParentShape<Types, Interfaces[number]>,
context: Types['Context'],
info: GraphQLResolveInfo,
) => boolean;
}

@@ -91,2 +88,8 @@ export interface RootTypeOptions<Types extends SchemaTypes, Type extends RootName>

interfaces?: Interfaces & ValidateInterfaces<Shape, Types, Interfaces[number]>[];
resolveType?: (
parent: Shape,
context: Types['Context'],
info: GraphQLResolveInfo,
type: GraphQLUnionType,
) => MaybePromise<ObjectParam<Types> | string | null | undefined>;
}

@@ -99,7 +102,8 @@

types: Member[];
resolveType: (
resolveType?: (
parent: ParentShape<Types, Member>,
context: Types['Context'],
info: GraphQLResolveInfo,
) => MaybePromise<Member | null | undefined>;
type: GraphQLUnionType,
) => MaybePromise<Member | string | null | undefined>;
}

@@ -106,0 +110,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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc