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-raw-loader
Advanced tools
Readme
Load GraphQL files as raw strings and handle it's import directive & comment statement.
Install it using NPM/Yarn.
# using NPM
npm i -D graphlq-raw-loader
# using Yarn
yarn add graphql-raw-loader --dev
Add graphql-raw-loader to your webpack configuration:
module.exports = {
// ...
module: {
rules: [
{
test: /\.(graphql|gql)$/,
loader: 'graphql-raw-loader'
}
]
}
}
fragment UserProfile on User {
# Some fields.
}
query Users {
users () {
...UserProfile @import(from: "./UserProfile.graphql")
}
}
import query from './User.graphl'
export const getUsers = async () => {
const response = await fetch('/api/graphql', {
body: JSON.stringify({ query }),
headers: {
'Content-Type': 'application/json',
},
})
const users = await response.json()
return users
}
Officially there's no way to import GraphQL files inside each other. Other loaders fixed it by parsing import statement inside a comment.
Also, theres a thread about implementing import statements on GraphQL. One of the best suggestions is about using a directive to import fragments.
This loader supports both ways. :sunglasses:
GraphQL loaders parses import statement inside comments.
# import "./UserDataFragment.graphql"
# The comment statement above is importing a file with UserDataFragment fragment
# inside it.
query Users {
users (is_active: True) {
data {
...UserDataFragment
}
}
}
@import
directivequery Users {
users (is_active: True) {
data {
...
}
...PaginationFragment @import(from: "./PaginationFragment.graphql")
# The directive above is importing a file with PaginationFragment fragment
# inside it.
}
}
FAQs
Load GraphQL files as raw strings and handle it's import directive & comment statement.
The npm package graphql-raw-loader receives a total of 9,196 weekly downloads. As such, graphql-raw-loader popularity was classified as popular.
We found that graphql-raw-loader 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.