
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.
apollo-link-form-data
Advanced tools
Send your GraphQL request with apollo-link as FormData or JSON.
Send your GraphQL request with apollo-link as FormData or JSON.
You can install this package from npm:
npm install apollo-link-form-data graphql
Or with yarn:
yarn add apollo-link-form-data graphql
For Node.js you also need to install following dependencies:
# 1. node-fetch ot any other fetch-compatible library instead of node-fetch
# 2. Note that you need at least 1.5.1 version of the formdata-node package
yarn add node-fetch formdata-node
And add this fetch
library to options manually:
import fetch from "node-fetch"
import {createFormDataLink} from "apollo-link-form-data"
const link = createFormDataLink({fetch})
Another thing I have to mention, is that ApolloLinkFormData uses @octetstream/object-to-form-data
package under the hood
to convert request payload to FormData which means that your data will be sent to server in spetial format.
For more info, read the API section of then-busboy documentation: then-busboy#bracket-notation
Of course, it doesn't mean that you have to use then-busboy on your server to process multipart/form-data
requests, but it must support mentioned format if you want to get usefull data out-of-the-box.
Import and initialize with just two lines:
import {createFormDataLink} from "apollo-link-form-data"
const link = createFormDataLink({uri: "https://api.example.com/graphql"})
Usage with Apollo Client:
import ApolloClient from "apollo-client"
import {InMemoryCache} from "apollo-cache-in-memory"
import {createFormDataLink} from "apollo-link-form-data"
const link = createFormDataLink({
uri: "https://api.example.com/graphql"
})
const cache = new InMemoryCache()
const client = ApolloClient({link, cache})
createFormDataLink(options) -> {ApolloLinkFormData}
Creates and instance of ApolloLinkFormData with given options.
true
, request payload will be always converted to FormData.
Defaults to false
which means that payload will be converted to FormData only when it contains at least one File.true
, all falsy booleans will be ignored. (See #1 PR in @octetstream/object-to-form-data
for mode info)More of available options you can find in ApolloLinkHttp documentation.
FAQs
Send your GraphQL request with apollo-link as FormData or JSON.
The npm package apollo-link-form-data receives a total of 7 weekly downloads. As such, apollo-link-form-data popularity was classified as not popular.
We found that apollo-link-form-data 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.