Utility library for extracting requested field names from GraphQL resolver info objects. Version 2.3.0 is current stable; released actively with semver. It parses GraphQLResolveInfo to return lists, maps (including nested), or MongoDB-like projection objects. Differentiators: simple API, built-in TypeScript types, and support for directives and field aliases. Alternatives like graphql-fields and graphql-parse-resolve-info have different APIs or are less maintained.
npm install graphql-fields-listNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use fieldsList, fieldsMap, and fieldsProjection in a resolver to extract requested fields from GraphQLResolveInfo.
Change fieldsMap(info, 'some.path', true) to fieldsMap(info, { path: 'some.path', withDirectives: true }).For nested fields, use fieldsMap and recursively extract keys, or consider using fieldsProjection which flattens nested paths.
To check if a field is requested, use if (fieldsMap(info)[field] !== undefined) or use fieldsList which returns an array.
Use named import: import { fieldsMap } from 'graphql-fields-list'Use options object: fieldsMap(info, { path: 'some.path' })No dependency data recorded yet.