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

@orbiting/graphql-list-fields

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orbiting/graphql-list-fields

Get a list of fields while resolving a GraphQL query

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
increased by218.18%
Maintainers
5
Weekly downloads
 
Created
Source

graphql-list-fields

This is a fork of: jakepusateri/graphql-list-field which adds named-inline-fragements (see description below). If the PR is merged into upstream, we'll get rid of the fork again.

When implementing a GraphQL server, it can be useful to know the list of fields being queried on a given type. This module takes a GraphQLResolveInfo object and returns a list of fields.

Supported features

  • Basic Fields
  • Fragments
  • Inline Fragments
  • @skip and @include directives
  • Nested fields into dot.notation
npm install --save graphql-list-fields

Usage

import getFieldNames from 'graphql-list-fields';

// in some resolve function
resolve(parent, args, context, info) {
    const fields = getFieldNames(info);
    return fetch('/someservice/?fields=' + fields.join(','));
}

named inline fragments

When supplying true as the second argument (getFieldList(ast, true)), the type of a spread is included in the path:

{
  someType {
    e {
      ... on NestedType {
        x
      }
    }
  }
}

results in: [e.NestedType.x] instead of [e.x]

Keywords

FAQs

Package last updated on 07 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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