Utility to extract field names from a GraphQLResolveInfo object during query resolution. Current stable version 2.0.4 (last updated 2019). Lightweight, supports fragments, inline fragments, @skip/@include directives, and nested dot-notation. Minimal alternative to apollo-server's field introspection or custom resolver logic.
npm install graphql-list-fieldsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates extracting field names from GraphQLResolveInfo in a resolver.
Deduplicate with Set or lodash.uniq.
Pass appropriate depth; depth 0 returns empty array.
Test with your GraphQL version; consider alternatives like graphql-parse-resolve-info.
Use graphql-parse-resolve-info for advanced introspection.
Change 'import { getFieldNames } from 'graphql-list-fields'' to 'import getFieldNames from 'graphql-list-fields''.Install @types/graphql-list-fields or create a declaration file: declare module 'graphql-list-fields';
Ensure getFieldNames is called with the 'info' parameter from a GraphQL resolver.