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

gql-pathify

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql-pathify

Parses GraphQL code to a flat list with paths to nodes being used.

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
decreased by-29.37%
Maintainers
1
Weekly downloads
 
Created
Source

gql-pathify

A lightweight + simple package for translating graphql requests into an array of paths to the nodes.

It won't add fields multiple times that gql will merge when resolving.

Eg:


query {
    a {
        a
        b
    }
    ...QueryFragment
}

fragment QueryFragment on RootQueryType {
    a {
        b 
        c
    }
}

will get translated to:

[
    'query',
    'query.a',
    'query.a.a',
    'query.a.b',
    'query.a.c',
]

When a field is aliased though, gql will resolve that multiple times, so its added multiple times.

EG:

query {
    a {
        a
        b
    }
    ...QueryFragment
}

fragment QueryFragment on RootQueryType {
    b: a {
        b
        c
    }
}

will be translated to

[
    'query',
    'query.a',
    'query.a.a',
    'query.a.b',
    'query.a',
    'query.a.b',
    'query.a.c',
]

Features:

  • Handles Inline fragments (recursively)
  • Handles normal Fragments (recursively)
  • Handles aliases
  • Returns the paths as many times as they are resolved - a field's path will only be added as much as it will be resolved.
  • 0 dependencies
  • Enforces a maximum field depth (handy if you don't want people querying too much data)
  • Enforces a maximum fragment depth (mostly since its recursive)

TODO:

  • Consider supporting skip directives.

FAQs

Package last updated on 20 Oct 2022

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