@croquiscom/crary-graphql
Advanced tools
Comparing version 0.4.0 to 0.5.0
import { GraphQLResolveInfo } from 'graphql'; | ||
export declare function getFieldList(info: GraphQLResolveInfo, fieldName?: string): string[]; | ||
export declare function getFieldList1st(info: GraphQLResolveInfo, fieldName?: string): string[]; | ||
export declare function getFieldList(info: GraphQLResolveInfo, field_path?: string | string[]): string[]; | ||
export declare function getFieldList1st(info: GraphQLResolveInfo, field_path?: string | string[]): string[]; |
@@ -66,22 +66,25 @@ "use strict"; | ||
} | ||
function getFieldList(info, fieldName) { | ||
if (fieldName) { | ||
const node = getSubFieldNode(info, info.fieldNodes, fieldName); | ||
if (node) { | ||
return Object.keys(getFieldSet(info, [node], '', 99999)); | ||
function getFieldListByDepth(info, field_path, depth) { | ||
if (typeof field_path === 'string') { | ||
field_path = [field_path]; | ||
} | ||
let nodes = info.fieldNodes; | ||
if (field_path.length > 0) { | ||
const field_node = field_path.slice(1).reduce((node, field_name) => node && getSubFieldNode(info, [node], field_name), getSubFieldNode(info, nodes, field_path[0])); | ||
if (field_node) { | ||
nodes = [field_node]; | ||
} | ||
return []; | ||
else { | ||
return []; | ||
} | ||
} | ||
else { | ||
return Object.keys(getFieldSet(info, info.fieldNodes, '', 99999)); | ||
} | ||
return Object.keys(getFieldSet(info, nodes, '', depth)); | ||
} | ||
function getFieldList(info, field_path = []) { | ||
return getFieldListByDepth(info, field_path, 99999); | ||
} | ||
exports.getFieldList = getFieldList; | ||
function getFieldList1st(info, fieldName) { | ||
if (fieldName) { | ||
const node = getSubFieldNode(info, info.fieldNodes, fieldName); | ||
return node ? Object.keys(getFieldSet(info, [node], '', 1)) : []; | ||
} | ||
return Object.keys(getFieldSet(info, info.fieldNodes, '', 1)); | ||
function getFieldList1st(info, field_path = []) { | ||
return getFieldListByDepth(info, field_path, 1); | ||
} | ||
exports.getFieldList1st = getFieldList1st; |
{ | ||
"name": "@croquiscom/crary-graphql", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Croquis's library - graphql extension", | ||
@@ -40,3 +40,3 @@ "main": "./lib", | ||
}, | ||
"gitHead": "00bff9c39ab6ce8dce2c7e55d41ea29586f743d2" | ||
"gitHead": "186afdc904505d5877aef4eb59389e015273374f" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
32219
708
1