Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@4c/graphql-relay-subscription

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4c/graphql-relay-subscription

Relay subscription helpers for GraphQL.js

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
4
Created
Source

graphql-relay-subscription Travis npm

Relay subscription helper for GraphQL.js.

Codecov Discord

Usage

As with mutationWithClientId in graphql-relay-js, subscriptionWithClientId creates subscriptions with single inputs and client subscription IDs.

import { parse, subscribe } from 'graphql';
import { subscriptionWithClientId } from 'graphql-relay-subscription';

/* ... */

const UpdateWidgetSubscription = subscriptionWithClientId({
  name: 'UpdateWidgetSubscription',
  inputFields: {
    widgetId: { type: GraphQLString },
  },
  outputFields: {
    widget: Widget,
  },
  subscribe: ({ widgetId }) =>
    createSubscription(`widgets:${widgetId}:updated`),
});

const subscription = await subscribe(
  schema,
  parse(`
    subscription ($input_0: UpdateWidgetSubscriptionInput!) {
      updateWidget(input: $input_0) {
        widget {
          name
        }
        clientSubscriptionId
      }
    }
  `),
  null,
  null,
  {
    input_0: {
      widgetId: 'foo',
      clientSubscriptionId: '0',
    },
  },
);

Keywords

graphql

FAQs

Package last updated on 24 Jan 2022

Did you know?

Socket

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.

Install

Related posts