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

@graphql-tools/documents

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/documents

Utilities for GraphQL documents.

  • 1.0.0-rc-20230517125140-6b16e710
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
decreased by-40.77%
Maintainers
3
Weekly downloads
 
Created
Source

@graphql-tools/documents

Utilities for GraphQL documents.

Install

yarn install @graphql-tools/documents

Contents

Print GraphQL Documents

A stable way to print a GraphQL document. All executable/fragment variable definitions, fields are printed in a stable way. Useful for stuff like persisted GraphQL operations.

Usage
import { parse } from 'graphql'
import { printExecutableGraphQLDocument } from '@graphql-tools/documents'

const inputDocument = parse(/* GraphQL */ `
  query A {
    ... on Query {
      a {
        ...B
        b
      }
    }
    ... on Query {
      a {
        ...B
        a
      }
    }
  }

  fragment B on Query {
    c
  }
`)
const outputStr = printExecutableGraphQLDocument(inputDocument)
console.assert(
  outputStr === 'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',
  'Stuff is not equal.'
)
Rules
  • Fragments are always printed before executable operations
  • Executable operations are sorted alphabetically by name.
  • Arguments (Directive, Fields) are sorted alphabetical
  • Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on TypeCondition, inner SelectionSet)

FAQs

Package last updated on 17 May 2023

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