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.
@shopify/koa-shopify-graphql-proxy
Advanced tools
Readme
@shopify/koa-shopify-graphql-proxy
A wrapper around koa-better-http-proxy
which allows easy proxying of GraphQL requests from an embedded Shopify app.
yarn add @shopify/koa-shopify-graphql-proxy
The module exports a proxy middleware as its default export. It expects that you have other middleware set up (such as koa-shopify-auth) to authenticate requests with Shopify, and have session data stored on ctx.session
.
Attaching the middleware will proxy any requests sent to /graphql
on your app to the current logged-in shop found in session.
// server/index.js
import koa from 'koa';
import session from 'koa-session';
import createShopifyAuth from '@shopify/koa-shopify-auth';
import proxy from '@shopify/koa-shopify-graphql-proxy';
const app = koa();
app.use(session());
app.use(
createShopifyAuth({
/* your config here */
}),
);
app.use(proxy({version: 'unstable'}));
This allows client-side scripts to query a logged-in merchant's shop without needing to know the user's access token.
fetch('/graphql', {credentials: 'include', body: mySerializedGraphQL});
If you have your own /graphql
route and don't want to clobber it, you can use a library like (koa-mount
)[https://github.com/koajs/mount] to namespace the middleware.
// server/index
import mount from 'koa-mount';
//....
app.use(mount('/shopify', proxy({version: 'unstable'}));
// client/some-component.js
fetch('/shopify/graphql', {credentials: 'include', body: mySerializedGraphQL});
If you have a private shopify app, you can than skip over the auth step and use this library directly for setting up graphql proxy.
// server/index.js
import koa from 'koa';
import session from 'koa-session';
import proxy from '@shopify/koa-shopify-graphql-proxy';
const app = koa();
app.use(session());
app.use(
proxy({
version: 'unstable',
shop: '<my-shop-name>.myshopify.com',
password: '<your-app-password>',
}),
);
FAQs
A wrapper around `koa-better-http-proxy` which allows easy proxying of GraphQL requests from an embedded Shopify app
The npm package @shopify/koa-shopify-graphql-proxy receives a total of 377 weekly downloads. As such, @shopify/koa-shopify-graphql-proxy popularity was classified as not popular.
We found that @shopify/koa-shopify-graphql-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 27 open source maintainers 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.