Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
graphql-import-macro
Advanced tools
Readme
A parser and expander for GraphQL imports, with minimal dependencies.
There is a relatively standardized syntax for imports in GraphQL. This library aims to provide a reference implementation with minimal dependencies.
The primary target audience of this library are tools that want to support a standardized GraphQL import.
npm install graphql-import-macro
import {parse, Source} from "graphql";
import {processDocumentImports} from "graphql-import-macro";
const ast = parse(new Source(content, path));
const resolvedAst = await processDocumentImports(ast);
console.log(resolvedAst);
Whitespace is ignored, except where necessary to parse tokens (import
, *
,
,
, and from
).
All matches of the following RegEX will be treated as imports:
#\s*import\s+(.+)\s*(?:\n|\r(?!\n)|\r\n|$)
See:
Import all:
#import 'path.graphql'
#import * from 'path.graphql'
Named Import:
#import A, B, C from 'path.graphql'
Group 1 from all imports will be matched against the following RegEx
^(?:(?:\*|((?:[_A-Za-z][_0-9A-Za-z]+\s*,\s*)*[_A-Za-z][_0-9A-Za-z]+))\s+from\s+|)?(?:'(.+)'|"(.+)")$
Each AST DocumentNode
must be created from a Source
instantiated with at
least two parameters. This ensures that correct path information is attached.
import {parse, Source} from "graphql";
const ast = parse(new Source(content, path));
processDocumentImports(ast, importResolver?)
Given an AST and optional resolver, parses imports and expands them recursively.
The loader argument can be passed to use custom loading logic and must conform to the following:
import type {DocumentNode} from "graphql";
let importResolver: (from: string, to: string) => Promise<DocumentNode>;
PRs accepted. Commit messages must conform to the default Semantic Release format.
Small note: If editing the Readme, please conform to the standard-readme specification.
FAQs
A simple parser and expander for GraphQL imports
The npm package graphql-import-macro receives a total of 17,653 weekly downloads. As such, graphql-import-macro popularity was classified as popular.
We found that graphql-import-macro demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.