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

@graphql-tools/utils

Package Overview
Dependencies
Maintainers
3
Versions
1282
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/utils - npm Package Compare versions

Comparing version 5.0.1-alpha-719b0ec.0 to 5.0.1-alpha-7ecf9b1.0

73

index.cjs.js

@@ -147,73 +147,2 @@ 'use strict';

function extractFieldResolversFromObjectType(objectType, options) {
const fieldResolvers = {};
const fieldMap = objectType.getFields();
let selectedFieldNames;
if (options && options.selectedTypeDefs) {
const invalidSchema = graphql.buildASTSchema(options.selectedTypeDefs);
const typeMap = invalidSchema.getTypeMap();
if (!(objectType.name in typeMap)) {
return {};
}
const selectedObjectType = typeMap[objectType.name];
selectedFieldNames = Object.keys(selectedObjectType.getFields());
}
for (const fieldName in fieldMap) {
if (selectedFieldNames && !selectedFieldNames.includes(fieldName)) {
continue;
}
const fieldDefinition = fieldMap[fieldName];
fieldResolvers[fieldName] = {
subscribe: fieldDefinition.subscribe,
resolve: fieldDefinition.resolve,
};
}
if ('resolveType' in objectType) {
fieldResolvers.__resolveType = objectType.resolveType;
}
if ('isTypeOf' in objectType) {
fieldResolvers.__isTypeOf = objectType.isTypeOf;
}
return fieldResolvers;
}
function extractResolversFromSchema(schema, options) {
let selectedTypeNames;
const resolvers = {};
const typeMap = schema.getTypeMap();
if (options && options.selectedTypeDefs) {
const invalidSchema = graphql.buildASTSchema(options.selectedTypeDefs);
selectedTypeNames = Object.keys(invalidSchema.getTypeMap());
}
for (const typeName in typeMap) {
if (!typeName.startsWith('__')) {
const typeDef = typeMap[typeName];
if (selectedTypeNames && !selectedTypeNames.includes(typeName)) {
continue;
}
if (graphql.isScalarType(typeDef)) {
resolvers[typeName] = typeDef;
}
else if (graphql.isObjectType(typeDef) || graphql.isInterfaceType(typeDef)) {
resolvers[typeName] = extractFieldResolversFromObjectType(typeDef, {
selectedTypeDefs: options && options.selectedTypeDefs,
});
}
else if (graphql.isEnumType(typeDef)) {
const enumValues = typeDef.getValues();
resolvers[typeName] = {};
for (const { name, value } of enumValues) {
resolvers[typeName][name] = value;
}
}
else if (graphql.isUnionType(typeDef)) {
resolvers[typeName] = {
__resolveType: typeDef.resolveType,
};
}
}
}
return resolvers;
}
const fixWindowsPath = (path) => path.replace(/\\/g, '/');

@@ -1000,4 +929,2 @@

exports.debugLog = debugLog;
exports.extractFieldResolversFromObjectType = extractFieldResolversFromObjectType;
exports.extractResolversFromSchema = extractResolversFromSchema;
exports.fixSchemaAst = fixSchemaAst;

@@ -1004,0 +931,0 @@ exports.fixWindowsPath = fixWindowsPath;

2

index.d.ts
export * from './loaders';
export * from './helpers';
export * from './debug-log';
export * from './extract-field-resolvers-from-object-type';
export * from './extract-resolvers-from-schema';
export * from './fix-windows-path';

@@ -7,0 +5,0 @@ export * from './flatten-array';

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

import { parse, buildASTSchema, isScalarType, isObjectType, isInterfaceType, isEnumType, isUnionType, getDirectiveValues, Kind, isSpecifiedScalarType, isIntrospectionType, print, printType, specifiedRules, validate, buildSchema, buildClientSchema, Source, isListType, isNonNullType, getNamedType } from 'graphql';
import { parse, getDirectiveValues, Kind, isObjectType, isScalarType, isSpecifiedScalarType, isIntrospectionType, print, printType, specifiedRules, validate, buildSchema, buildClientSchema, Source, isListType, isNonNullType, getNamedType, isUnionType, isInterfaceType } from 'graphql';
import AggregateError from 'aggregate-error';

@@ -122,73 +122,2 @@ import { get, set } from 'lodash';

function extractFieldResolversFromObjectType(objectType, options) {
const fieldResolvers = {};
const fieldMap = objectType.getFields();
let selectedFieldNames;
if (options && options.selectedTypeDefs) {
const invalidSchema = buildASTSchema(options.selectedTypeDefs);
const typeMap = invalidSchema.getTypeMap();
if (!(objectType.name in typeMap)) {
return {};
}
const selectedObjectType = typeMap[objectType.name];
selectedFieldNames = Object.keys(selectedObjectType.getFields());
}
for (const fieldName in fieldMap) {
if (selectedFieldNames && !selectedFieldNames.includes(fieldName)) {
continue;
}
const fieldDefinition = fieldMap[fieldName];
fieldResolvers[fieldName] = {
subscribe: fieldDefinition.subscribe,
resolve: fieldDefinition.resolve,
};
}
if ('resolveType' in objectType) {
fieldResolvers.__resolveType = objectType.resolveType;
}
if ('isTypeOf' in objectType) {
fieldResolvers.__isTypeOf = objectType.isTypeOf;
}
return fieldResolvers;
}
function extractResolversFromSchema(schema, options) {
let selectedTypeNames;
const resolvers = {};
const typeMap = schema.getTypeMap();
if (options && options.selectedTypeDefs) {
const invalidSchema = buildASTSchema(options.selectedTypeDefs);
selectedTypeNames = Object.keys(invalidSchema.getTypeMap());
}
for (const typeName in typeMap) {
if (!typeName.startsWith('__')) {
const typeDef = typeMap[typeName];
if (selectedTypeNames && !selectedTypeNames.includes(typeName)) {
continue;
}
if (isScalarType(typeDef)) {
resolvers[typeName] = typeDef;
}
else if (isObjectType(typeDef) || isInterfaceType(typeDef)) {
resolvers[typeName] = extractFieldResolversFromObjectType(typeDef, {
selectedTypeDefs: options && options.selectedTypeDefs,
});
}
else if (isEnumType(typeDef)) {
const enumValues = typeDef.getValues();
resolvers[typeName] = {};
for (const { name, value } of enumValues) {
resolvers[typeName][name] = value;
}
}
else if (isUnionType(typeDef)) {
resolvers[typeName] = {
__resolveType: typeDef.resolveType,
};
}
}
}
return resolvers;
}
const fixWindowsPath = (path) => path.replace(/\\/g, '/');

@@ -966,3 +895,3 @@

export { asArray, buildOperationNodeForField, chainFunctions, checkValidationErrors, compareNodes, compareStrings, composeResolvers, createSchemaDefinition, debugLog, extractFieldResolversFromObjectType, extractResolversFromSchema, fixSchemaAst, fixWindowsPath, flattenArray, getDirectives, getFieldsWithDirectives, getImplementingTypes, getUserTypesFromSchema, isDocumentString, isEqual, isNotEqual, isValidPath, nodeToString, parseGraphQLJSON, parseGraphQLSDL, printSchemaWithDirectives, resolveBuiltinModule, resolveBuiltinModuleSync, validateGraphQlDocuments };
export { asArray, buildOperationNodeForField, chainFunctions, checkValidationErrors, compareNodes, compareStrings, composeResolvers, createSchemaDefinition, debugLog, fixSchemaAst, fixWindowsPath, flattenArray, getDirectives, getFieldsWithDirectives, getImplementingTypes, getUserTypesFromSchema, isDocumentString, isEqual, isNotEqual, isValidPath, nodeToString, parseGraphQLJSON, parseGraphQLSDL, printSchemaWithDirectives, resolveBuiltinModule, resolveBuiltinModuleSync, validateGraphQlDocuments };
//# sourceMappingURL=index.esm.js.map

5

package.json
{
"name": "@graphql-tools/utils",
"version": "5.0.1-alpha-719b0ec.0",
"version": "5.0.1-alpha-7ecf9b1.0",
"description": "Common package containting utils and types for GraphQL tools",
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
"graphql": "^14.0.0 || ^15.0.0"
},

@@ -11,3 +11,2 @@ "dependencies": {

"camel-case": "4.1.1",
"@graphql-tools/schema-stitching": "5.0.1-alpha-719b0ec.0",
"lodash": "4.17.15"

@@ -14,0 +13,0 @@ },

@@ -1,6 +0,6 @@

import { IResolvers, IFieldResolver } from '@graphql-tools/schema-stitching';
export declare type ResolversComposition<Resolver extends IFieldResolver<any, any> = IFieldResolver<any, any>> = (next: Resolver) => Resolver;
export declare type ResolversComposerMapping<Resolvers extends IResolvers = IResolvers> = {
import { GraphQLFieldResolver } from 'graphql';
export declare type ResolversComposition<Resolver extends GraphQLFieldResolver<any, any> = GraphQLFieldResolver<any, any>> = (next: Resolver) => Resolver;
export declare type ResolversComposerMapping<Resolvers extends Record<string, any> = Record<string, any>> = {
[TypeName in keyof Resolvers]?: {
[FieldName in keyof Resolvers[TypeName]]: Resolvers[TypeName][FieldName] extends IFieldResolver<any, any> ? ResolversComposition<Resolvers[TypeName][FieldName]> | Array<ResolversComposition<Resolvers[TypeName][FieldName]>> : ResolversComposition | ResolversComposition[];
[FieldName in keyof Resolvers[TypeName]]: Resolvers[TypeName][FieldName] extends GraphQLFieldResolver<any, any> ? ResolversComposition<Resolvers[TypeName][FieldName]> | Array<ResolversComposition<Resolvers[TypeName][FieldName]>> : ResolversComposition | ResolversComposition[];
};

@@ -18,2 +18,2 @@ } | {

*/
export declare function composeResolvers<Resolvers extends IResolvers>(resolvers: Resolvers, mapping?: ResolversComposerMapping<Resolvers>): Resolvers;
export declare function composeResolvers<Resolvers extends Record<string, any>>(resolvers: Resolvers, mapping?: ResolversComposerMapping<Resolvers>): Resolvers;

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