
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Lightweight GraphQL request/client aimed at usage in the browser. Can also be
used in Node by providing your own implementation of fetch
.
Built to be used for minimal use cases or with any Promise
based data-fetching
abstraction such as react-query
.
ASTNode
s from graphql-tag
.# npm
npm install simple-gql
# yarn
yarn add simple-gql
import { gqlFetch } from 'simple-gql'
const query = `
query getBook($title: String!) {
Book(title: $title) {
publishDate
author {
name
}
}
}
`
const response = await gqlFetch({
url: 'https://book-api/graphql',
query,
variables: { title: 'Example Title' },
})
graphql-tag
and TypeScriptimport { gqlFetch } from 'simple-gql'
import gql from 'graphql-tag'
interface QueryVaraibles {
title: string
}
interface QueryData {
Book: {
publishDate: number
author: {
name: string
}
}
}
const query = gql`
query getBook($title: String!) {
Book(title: $title) {
publishDate
author {
name
}
}
}
`
const response = await gqlFetch<QueryData, QueryVariables>({
url: 'https://book-api/graphql',
query,
variables: { title: 'Example Title' },
})
We can create a reusable client with some function composition and closures. See the example below for a TypeScript example.
import { gqlFetch } from 'simple-gql'
import { ASTNode } from 'graphql'
export const gqlRequest = async <T, V>(
query: string | ASTNode,
variables: V,
) => {
// Perform any pre-request logic you need here.
const accessToken = myTokenLogic()
const response = await gqlFetch<T, V>({
query,
variables,
url: 'https://your-endpoint.com/graphql',
options: {
// Your default options.
headers: {
Authorization: `token ${accessToken}`,
},
},
})
return response
}
This library will make no attempt to handle your errors and leaves it up to the
developer to handle them. It will throw any error it receives, just like a
fetch
request would.
gqlFetch
Make a plain GraphQL request.
const gqlFetch: <T>({ url: string, query: string | ASTNode, variables?: object, options?: Options, }) => Promise<T>
Accepts an object as a parameter with the following keys:
url
: The endpoint to request.query
: GraphQL query as a string or ASTNode
returned from graphql-tag
.variables
: GraphQL variable object to inject into your query.options
: Options. See options for all available options.Returns a Promise
.
gqlFetch
takes an options
object that accepts the same options a normal
fetch
would accept in addition to the following:
fetch
: Fetch implementation to utilize. Defaults to window.fetch
. Use this
if you plan to use this package in Node.If you need to send your GraphQL request via GET, just set the appropriate
headers.method
option. gqlFetch
will handle setting your query
and
variables
as querystring parameters.
MIT.
FAQs
Lightweight GraphQL request utiltiy.
We found that simple-gql 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.