Newton's Preposterous Miscalculation

    @4c/graphql-relay-subscription
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.0 • Public • Published

    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',
        },
      },
    );

    Install

    npm i @4c/graphql-relay-subscription

    DownloadsWeekly Downloads

    1,932

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    7.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • stephen_liu
    • monastic.panic
    • sloria