
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
graphql-tag.macro
Advanced tools
Babel Macro for the graphql-tag library.
It inlines the result of parsing the GraphQL queries with graphql-tag
.
Converts this:
const query = gql`
query {
hello {
world
}
}
`;
To this:
const query = {
'kind': 'Document',
'definitions': [{
'kind': 'OperationDefinition',
'operation': 'query',
'variableDefinitions': [],
'directives': [],
'selectionSet': {
'kind': 'SelectionSet',
'selections': [{
'kind': 'Field',
'alias': null,
'name': {
'kind': 'Name',
'value': 'hello'
},
'arguments': [],
'directives': [],
'selectionSet': {
'kind': 'SelectionSet',
'selections': [{
'kind': 'Field',
'alias': null,
'name': {
'kind': 'Name',
'value': 'world'
},
'arguments': [],
'directives': [],
'selectionSet': null
}]
}
}]
}
}],
'loc': {
'start': 0,
'end': 45,
'source': {
'body': '\\\\n query {\\\\n hello {\\\\n world\\\\n }\\\\n }\\\\n',
'name': 'GraphQL request',
'locationOffset': {
'line': 1,
'column': 1
}
}
}
};
It also supports adding interpolated fragments:
const frag = gql`
fragment Frag on Hello {
world
}
`;
const query = gql`
query {
hello {
universe
...Frag
}
}
${frag}
`;
To avoid the runtime overhead of parsing a string into a GraphQL AST.
Install and configure babel-macros if you haven't already.
Then install this package:
# with yarn
yarn add -D graphql-tag.macro
# with npm
npm install -D graphql-tag.macro
The usage is the same as using graphql-tag directly, the only difference is that you have to import gql
from the macro now:
import gql from 'graphql-tag.macro';
const query = gql`
query {
hello {
world
}
}
`;
FAQs
graphql-tag as a babel-macro
The npm package graphql-tag.macro receives a total of 7,957 weekly downloads. As such, graphql-tag.macro popularity was classified as popular.
We found that graphql-tag.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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.