@pothos/plugin-sub-graph
Advanced tools
Comparing version 4.0.2 to 4.1.0
# Change Log | ||
## 4.1.0 | ||
### Minor Changes | ||
- 27af377: replace eslint and prettier with biome | ||
## 4.0.2 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { FieldNullability, FieldRequiredness, InputFieldMap, InputShapeFromTypeParam, InputType, InterfaceParam, RootName, SchemaTypes, TypeParam } from '@pothos/core'; | ||
import type { FieldNullability, FieldRequiredness, InputFieldMap, InputShapeFromTypeParam, InputType, InterfaceParam, RootName, SchemaTypes, TypeParam } from '@pothos/core'; | ||
import type { PothosSubGraphPlugin } from '.'; | ||
@@ -3,0 +3,0 @@ declare global { |
import './global-types'; | ||
import { GraphQLFieldConfigMap, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLSchema } from 'graphql'; | ||
import { BasePlugin, PothosInputFieldConfig, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes } from '@pothos/core'; | ||
import { BasePlugin, type PothosInputFieldConfig, type PothosOutputFieldConfig, type PothosTypeConfig, type SchemaTypes } from '@pothos/core'; | ||
import { type GraphQLFieldConfigMap, type GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInterfaceType, type GraphQLNamedType, GraphQLObjectType, GraphQLSchema } from 'graphql'; | ||
declare const pluginName = "subGraph"; | ||
@@ -63,3 +63,3 @@ export default pluginName; | ||
extensionASTNodes?: import("graphql/jsutils/Maybe").Maybe<ReadonlyArray<import("graphql").InputObjectTypeExtensionNode>>; | ||
isOneOf?: boolean; | ||
isOneOf?: boolean | undefined; | ||
} | { | ||
@@ -66,0 +66,0 @@ extensions: { |
@@ -1,3 +0,3 @@ | ||
import { GraphQLNamedType, GraphQLType } from 'graphql'; | ||
import { type GraphQLNamedType, type GraphQLType } from 'graphql'; | ||
export declare function replaceType<T extends GraphQLType>(type: T, newTypes: Map<string, GraphQLNamedType>, referencedBy: string, subGraphs: string[]): T; | ||
//# sourceMappingURL=util.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { FieldNullability, FieldRequiredness, InputFieldMap, InputShapeFromTypeParam, InputType, InterfaceParam, RootName, SchemaTypes, TypeParam } from '@pothos/core'; | ||
import type { FieldNullability, FieldRequiredness, InputFieldMap, InputShapeFromTypeParam, InputType, InterfaceParam, RootName, SchemaTypes, TypeParam } from '@pothos/core'; | ||
import type { PothosSubGraphPlugin } from './index.js'; | ||
@@ -3,0 +3,0 @@ declare global { |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ export {}; | ||
export {}; | ||
//# sourceMappingURL=global-types.js.map |
import './global-types.js'; | ||
import { GraphQLFieldConfigMap, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLSchema } from 'graphql'; | ||
import { BasePlugin, PothosInputFieldConfig, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes } from '@pothos/core'; | ||
import { BasePlugin, type PothosInputFieldConfig, type PothosOutputFieldConfig, type PothosTypeConfig, type SchemaTypes } from '@pothos/core'; | ||
import { type GraphQLFieldConfigMap, type GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInterfaceType, type GraphQLNamedType, GraphQLObjectType, GraphQLSchema } from 'graphql'; | ||
declare const pluginName = "subGraph"; | ||
@@ -63,3 +63,3 @@ export default pluginName; | ||
extensionASTNodes?: import("graphql/jsutils/Maybe.js").Maybe<ReadonlyArray<import("graphql").InputObjectTypeExtensionNode>>; | ||
isOneOf?: boolean; | ||
isOneOf?: boolean | undefined; | ||
} | { | ||
@@ -66,0 +66,0 @@ extensions: { |
@@ -1,4 +0,4 @@ | ||
/* eslint-disable prefer-destructuring */ import './global-types.js'; | ||
import { getNamedType, GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType, isInterfaceType, isNonNullType, isObjectType } from 'graphql'; | ||
import './global-types.js'; | ||
import SchemaBuilder, { BasePlugin, PothosSchemaError } from '@pothos/core'; | ||
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType, getNamedType, isInterfaceType, isNonNullType, isObjectType } from 'graphql'; | ||
import { replaceType } from './util.js'; | ||
@@ -21,3 +21,3 @@ const pluginName = "subGraph"; | ||
const config = schema.toConfig(); | ||
const newTypes = this.filterTypes(config.types, subGraphs); | ||
const newTypes = PothosSubGraphPlugin.filterTypes(config.types, subGraphs); | ||
const returnedInterfaces = new Set(); | ||
@@ -62,6 +62,6 @@ for (const type of newTypes.values()) { | ||
const newTypes = new Map(); | ||
types.forEach((type) => { | ||
for (const type of types) { | ||
var _type_extensions; | ||
if (type.name.startsWith("__")) { | ||
return; | ||
continue; | ||
} | ||
@@ -72,3 +72,3 @@ if (type.name === "String" || type.name === "Int" || type.name === "Float" || type.name === "Boolean" || type.name === "ID") { | ||
if (!intersect(((_type_extensions = type.extensions) === null || _type_extensions === void 0 ? void 0 : _type_extensions.subGraphs) || [], subGraphs)) { | ||
return; | ||
continue; | ||
} | ||
@@ -83,3 +83,3 @@ if (type instanceof GraphQLScalarType || type instanceof GraphQLEnumType) { | ||
interfaces: () => typeConfig.interfaces.filter((iface) => newTypes.has(iface.name)).map((iface) => replaceType(iface, newTypes, typeConfig.name, subGraphs)), | ||
fields: this.filterFields(type, newTypes, subGraphs) | ||
fields: PothosSubGraphPlugin.filterFields(type, newTypes, subGraphs) | ||
})); | ||
@@ -92,3 +92,3 @@ } | ||
interfaces: () => typeConfig.interfaces.map((iface) => replaceType(iface, newTypes, typeConfig.name, subGraphs)), | ||
fields: this.filterFields(type, newTypes, subGraphs) | ||
fields: PothosSubGraphPlugin.filterFields(type, newTypes, subGraphs) | ||
})); | ||
@@ -107,6 +107,6 @@ } | ||
...typeConfig, | ||
fields: this.mapInputFields(type, newTypes, subGraphs) | ||
fields: PothosSubGraphPlugin.mapInputFields(type, newTypes, subGraphs) | ||
})); | ||
} | ||
}); | ||
} | ||
return newTypes; | ||
@@ -118,11 +118,10 @@ } | ||
const newFields = {}; | ||
Object.keys(oldFields).forEach((fieldName) => { | ||
for (const [fieldName, fieldConfig] of Object.entries(oldFields)) { | ||
var _fieldConfig_extensions; | ||
const fieldConfig = oldFields[fieldName]; | ||
const newArguments = {}; | ||
var _fieldConfig_extensions_subGraphs; | ||
if (!intersect((_fieldConfig_extensions_subGraphs = (_fieldConfig_extensions = fieldConfig.extensions) === null || _fieldConfig_extensions === void 0 ? void 0 : _fieldConfig_extensions.subGraphs) !== null && _fieldConfig_extensions_subGraphs !== void 0 ? _fieldConfig_extensions_subGraphs : [], subGraphs) || !newTypes.has(getNamedType(fieldConfig.type).name)) { | ||
return; | ||
continue; | ||
} | ||
fieldConfig.args.forEach((argConfig) => { | ||
for (const argConfig of fieldConfig.args) { | ||
var _argConfig_extensions; | ||
@@ -134,3 +133,3 @@ const argSubGraphs = (_argConfig_extensions = argConfig.extensions) === null || _argConfig_extensions === void 0 ? void 0 : _argConfig_extensions.subGraphs; | ||
} | ||
return; | ||
continue; | ||
} | ||
@@ -145,3 +144,3 @@ newArguments[argConfig.name] = { | ||
}; | ||
}); | ||
} | ||
newFields[fieldName] = { | ||
@@ -157,3 +156,3 @@ description: fieldConfig.description, | ||
}; | ||
}); | ||
} | ||
return newFields; | ||
@@ -166,5 +165,4 @@ }; | ||
const newFields = {}; | ||
Object.keys(oldFields).forEach((fieldName) => { | ||
for (const [fieldName, fieldConfig] of Object.entries(oldFields)) { | ||
var _fieldConfig_extensions; | ||
const fieldConfig = oldFields[fieldName]; | ||
const fieldSubGraphs = (_fieldConfig_extensions = fieldConfig.extensions) === null || _fieldConfig_extensions === void 0 ? void 0 : _fieldConfig_extensions.subGraphs; | ||
@@ -175,3 +173,3 @@ if (fieldSubGraphs && !intersect(fieldSubGraphs, subGraphs)) { | ||
} | ||
return; | ||
continue; | ||
} | ||
@@ -186,3 +184,3 @@ newFields[fieldName] = { | ||
}; | ||
}); | ||
} | ||
return newFields; | ||
@@ -189,0 +187,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
import { GraphQLNamedType, GraphQLType } from 'graphql'; | ||
import { type GraphQLNamedType, type GraphQLType } from 'graphql'; | ||
export declare function replaceType<T extends GraphQLType>(type: T, newTypes: Map<string, GraphQLNamedType>, referencedBy: string, subGraphs: string[]): T; | ||
//# sourceMappingURL=util.d.ts.map |
@@ -0,3 +1,3 @@ | ||
import { PothosSchemaError } from '@pothos/core'; | ||
import { GraphQLList, GraphQLNonNull } from 'graphql'; | ||
import { PothosSchemaError } from '@pothos/core'; | ||
export function replaceType(type, newTypes, referencedBy, subGraphs) { | ||
@@ -4,0 +4,0 @@ if (type instanceof GraphQLNonNull) { |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ "use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -3,0 +3,0 @@ value: true |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable prefer-destructuring */ "use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -20,4 +20,4 @@ value: true | ||
require("./global-types"); | ||
const _core = /*#__PURE__*/ _interop_require_wildcard(require("@pothos/core")); | ||
const _graphql = require("graphql"); | ||
const _core = /*#__PURE__*/ _interop_require_wildcard(require("@pothos/core")); | ||
const _util = require("./util"); | ||
@@ -81,3 +81,3 @@ function _getRequireWildcardCache(nodeInterop) { | ||
const config = schema.toConfig(); | ||
const newTypes = this.filterTypes(config.types, subGraphs); | ||
const newTypes = PothosSubGraphPlugin.filterTypes(config.types, subGraphs); | ||
const returnedInterfaces = new Set(); | ||
@@ -122,6 +122,6 @@ for (const type of newTypes.values()){ | ||
const newTypes = new Map(); | ||
types.forEach((type)=>{ | ||
for (const type of types){ | ||
var _type_extensions; | ||
if (type.name.startsWith('__')) { | ||
return; | ||
continue; | ||
} | ||
@@ -132,3 +132,3 @@ if (type.name === 'String' || type.name === 'Int' || type.name === 'Float' || type.name === 'Boolean' || type.name === 'ID') { | ||
if (!intersect(((_type_extensions = type.extensions) === null || _type_extensions === void 0 ? void 0 : _type_extensions.subGraphs) || [], subGraphs)) { | ||
return; | ||
continue; | ||
} | ||
@@ -142,3 +142,3 @@ if (type instanceof _graphql.GraphQLScalarType || type instanceof _graphql.GraphQLEnumType) { | ||
interfaces: ()=>typeConfig.interfaces.filter((iface)=>newTypes.has(iface.name)).map((iface)=>(0, _util.replaceType)(iface, newTypes, typeConfig.name, subGraphs)), | ||
fields: this.filterFields(type, newTypes, subGraphs) | ||
fields: PothosSubGraphPlugin.filterFields(type, newTypes, subGraphs) | ||
})); | ||
@@ -150,3 +150,3 @@ } else if (type instanceof _graphql.GraphQLInterfaceType) { | ||
interfaces: ()=>typeConfig.interfaces.map((iface)=>(0, _util.replaceType)(iface, newTypes, typeConfig.name, subGraphs)), | ||
fields: this.filterFields(type, newTypes, subGraphs) | ||
fields: PothosSubGraphPlugin.filterFields(type, newTypes, subGraphs) | ||
})); | ||
@@ -163,6 +163,6 @@ } else if (type instanceof _graphql.GraphQLUnionType) { | ||
...typeConfig, | ||
fields: this.mapInputFields(type, newTypes, subGraphs) | ||
fields: PothosSubGraphPlugin.mapInputFields(type, newTypes, subGraphs) | ||
})); | ||
} | ||
}); | ||
} | ||
return newTypes; | ||
@@ -174,11 +174,10 @@ } | ||
const newFields = {}; | ||
Object.keys(oldFields).forEach((fieldName)=>{ | ||
for (const [fieldName, fieldConfig] of Object.entries(oldFields)){ | ||
var _fieldConfig_extensions; | ||
const fieldConfig = oldFields[fieldName]; | ||
const newArguments = {}; | ||
var _fieldConfig_extensions_subGraphs; | ||
if (!intersect((_fieldConfig_extensions_subGraphs = (_fieldConfig_extensions = fieldConfig.extensions) === null || _fieldConfig_extensions === void 0 ? void 0 : _fieldConfig_extensions.subGraphs) !== null && _fieldConfig_extensions_subGraphs !== void 0 ? _fieldConfig_extensions_subGraphs : [], subGraphs) || !newTypes.has((0, _graphql.getNamedType)(fieldConfig.type).name)) { | ||
return; | ||
continue; | ||
} | ||
fieldConfig.args.forEach((argConfig)=>{ | ||
for (const argConfig of fieldConfig.args){ | ||
var _argConfig_extensions; | ||
@@ -190,3 +189,3 @@ const argSubGraphs = (_argConfig_extensions = argConfig.extensions) === null || _argConfig_extensions === void 0 ? void 0 : _argConfig_extensions.subGraphs; | ||
} | ||
return; | ||
continue; | ||
} | ||
@@ -201,3 +200,3 @@ newArguments[argConfig.name] = { | ||
}; | ||
}); | ||
} | ||
newFields[fieldName] = { | ||
@@ -213,3 +212,3 @@ description: fieldConfig.description, | ||
}; | ||
}); | ||
} | ||
return newFields; | ||
@@ -222,5 +221,4 @@ }; | ||
const newFields = {}; | ||
Object.keys(oldFields).forEach((fieldName)=>{ | ||
for (const [fieldName, fieldConfig] of Object.entries(oldFields)){ | ||
var _fieldConfig_extensions; | ||
const fieldConfig = oldFields[fieldName]; | ||
const fieldSubGraphs = (_fieldConfig_extensions = fieldConfig.extensions) === null || _fieldConfig_extensions === void 0 ? void 0 : _fieldConfig_extensions.subGraphs; | ||
@@ -231,3 +229,3 @@ if (fieldSubGraphs && !intersect(fieldSubGraphs, subGraphs)) { | ||
} | ||
return; | ||
continue; | ||
} | ||
@@ -242,3 +240,3 @@ newFields[fieldName] = { | ||
}; | ||
}); | ||
} | ||
return newFields; | ||
@@ -245,0 +243,0 @@ }; |
@@ -11,4 +11,4 @@ "use strict"; | ||
}); | ||
const _core = require("@pothos/core"); | ||
const _graphql = require("graphql"); | ||
const _core = require("@pothos/core"); | ||
function replaceType(type, newTypes, referencedBy, subGraphs) { | ||
@@ -15,0 +15,0 @@ if (type instanceof _graphql.GraphQLNonNull) { |
{ | ||
"name": "@pothos/plugin-sub-graph", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "A Pothos plugin for creating multiple variants or sub-selections of the same graph", | ||
@@ -42,3 +42,3 @@ "main": "./lib/index.js", | ||
"peerDependencies": { | ||
"@pothos/core": "4.0.2", | ||
"@pothos/core": "*", | ||
"graphql": ">=16.6.0" | ||
@@ -49,7 +49,7 @@ }, | ||
"graphql-tag": "^2.12.6", | ||
"@pothos/core": "4.0.2", | ||
"@pothos/plugin-errors": "4.0.2", | ||
"@pothos/plugin-relay": "4.0.2", | ||
"@pothos/plugin-with-input": "4.0.2", | ||
"@pothos/test-utils": "2.0.1" | ||
"@pothos/core": "4.1.0", | ||
"@pothos/plugin-errors": "4.2.0", | ||
"@pothos/plugin-relay": "4.1.0", | ||
"@pothos/plugin-with-input": "4.1.0", | ||
"@pothos/test-utils": "2.1.0" | ||
}, | ||
@@ -56,0 +56,0 @@ "gitHead": "9dfe52f1975f41a111e01bf96a20033a914e2acc", |
@@ -1,3 +0,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { | ||
import type { | ||
FieldNullability, | ||
@@ -4,0 +3,0 @@ FieldRequiredness, |
@@ -1,12 +0,18 @@ | ||
/* eslint-disable prefer-destructuring */ | ||
import './global-types'; | ||
import SchemaBuilder, { | ||
BasePlugin, | ||
type PothosInputFieldConfig, | ||
type PothosOutputFieldConfig, | ||
PothosSchemaError, | ||
type PothosTypeConfig, | ||
type SchemaTypes, | ||
} from '@pothos/core'; | ||
import { | ||
getNamedType, | ||
GraphQLEnumType, | ||
GraphQLFieldConfigArgumentMap, | ||
GraphQLFieldConfigMap, | ||
GraphQLInputFieldConfigMap, | ||
type GraphQLFieldConfigArgumentMap, | ||
type GraphQLFieldConfigMap, | ||
type GraphQLInputFieldConfigMap, | ||
GraphQLInputObjectType, | ||
GraphQLInterfaceType, | ||
GraphQLNamedType, | ||
type GraphQLNamedType, | ||
GraphQLObjectType, | ||
@@ -16,2 +22,3 @@ GraphQLScalarType, | ||
GraphQLUnionType, | ||
getNamedType, | ||
isInterfaceType, | ||
@@ -21,10 +28,2 @@ isNonNullType, | ||
} from 'graphql'; | ||
import SchemaBuilder, { | ||
BasePlugin, | ||
PothosInputFieldConfig, | ||
PothosOutputFieldConfig, | ||
PothosSchemaError, | ||
PothosTypeConfig, | ||
SchemaTypes, | ||
} from '@pothos/core'; | ||
import { replaceType } from './util'; | ||
@@ -51,3 +50,3 @@ | ||
const config = schema.toConfig(); | ||
const newTypes = this.filterTypes(config.types, subGraphs); | ||
const newTypes = PothosSubGraphPlugin.filterTypes(config.types, subGraphs); | ||
const returnedInterfaces = new Set<string>(); | ||
@@ -101,5 +100,5 @@ | ||
types.forEach((type) => { | ||
for (const type of types) { | ||
if (type.name.startsWith('__')) { | ||
return; | ||
continue; | ||
} | ||
@@ -118,3 +117,3 @@ | ||
if (!intersect((type.extensions?.subGraphs as string[]) || [], subGraphs)) { | ||
return; | ||
continue; | ||
} | ||
@@ -134,3 +133,3 @@ | ||
.map((iface) => replaceType(iface, newTypes, typeConfig.name, subGraphs)), | ||
fields: this.filterFields(type, newTypes, subGraphs), | ||
fields: PothosSubGraphPlugin.filterFields(type, newTypes, subGraphs), | ||
}), | ||
@@ -148,3 +147,3 @@ ); | ||
), | ||
fields: this.filterFields(type, newTypes, subGraphs), | ||
fields: PothosSubGraphPlugin.filterFields(type, newTypes, subGraphs), | ||
}), | ||
@@ -170,7 +169,7 @@ ); | ||
...typeConfig, | ||
fields: this.mapInputFields(type, newTypes, subGraphs), | ||
fields: PothosSubGraphPlugin.mapInputFields(type, newTypes, subGraphs), | ||
}), | ||
); | ||
} | ||
}); | ||
} | ||
@@ -190,5 +189,3 @@ return newTypes; | ||
Object.keys(oldFields).forEach((fieldName) => { | ||
const fieldConfig = oldFields[fieldName]; | ||
for (const [fieldName, fieldConfig] of Object.entries(oldFields)) { | ||
const newArguments: GraphQLFieldConfigArgumentMap = {}; | ||
@@ -203,6 +200,6 @@ | ||
) { | ||
return; | ||
continue; | ||
} | ||
fieldConfig.args.forEach((argConfig) => { | ||
for (const argConfig of fieldConfig.args) { | ||
const argSubGraphs = argConfig.extensions?.subGraphs as string[] | undefined; | ||
@@ -217,3 +214,3 @@ | ||
return; | ||
continue; | ||
} | ||
@@ -234,3 +231,3 @@ | ||
}; | ||
}); | ||
} | ||
@@ -252,3 +249,3 @@ newFields[fieldName] = { | ||
}; | ||
}); | ||
} | ||
@@ -269,4 +266,3 @@ return newFields; | ||
Object.keys(oldFields).forEach((fieldName) => { | ||
const fieldConfig = oldFields[fieldName]; | ||
for (const [fieldName, fieldConfig] of Object.entries(oldFields)) { | ||
const fieldSubGraphs = fieldConfig.extensions?.subGraphs as string[] | undefined; | ||
@@ -281,3 +277,3 @@ | ||
return; | ||
continue; | ||
} | ||
@@ -298,3 +294,3 @@ | ||
}; | ||
}); | ||
} | ||
@@ -301,0 +297,0 @@ return newFields; |
@@ -1,3 +0,3 @@ | ||
import { GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLType } from 'graphql'; | ||
import { PothosSchemaError } from '@pothos/core'; | ||
import { GraphQLList, type GraphQLNamedType, GraphQLNonNull, type GraphQLType } from 'graphql'; | ||
@@ -4,0 +4,0 @@ export function replaceType<T extends GraphQLType>( |
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
114953
1603