Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@n1ru4l/graphql-live-query

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n1ru4l/graphql-live-query

[![npm version](https://img.shields.io/npm/v/@n1ru4l/graphql-live-query.svg)](https://www.npmjs.com/package/@n1ru4l/graphql-live-query) [![npm downloads](https://img.shields.io/npm/dm/@n1ru4l/graphql-live-query.svg)](https://www.npmjs.com/package/@n1ru4l/

  • 0.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @n1ru4l/graphql-live-query?

@n1ru4l/graphql-live-query is a package that enables live queries in GraphQL. It allows clients to receive real-time updates when the result of a query changes, providing a more dynamic and interactive experience.

What are @n1ru4l/graphql-live-query's main functionalities?

Live Queries

This feature allows you to set up live queries in your GraphQL server. The code sample demonstrates how to integrate live queries using the @n1ru4l/graphql-live-query package.

const { execute, subscribe } = require('@n1ru4l/graphql-live-query');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const { useLiveQuery } = require('@n1ru4l/graphql-live-query');

const typeDefs = `
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};

const schema = makeExecutableSchema({ typeDefs, resolvers });

const liveQueryStore = new LiveQueryStore();

const executeWithLiveQueries = useLiveQuery({
  execute,
  subscribe,
  liveQueryStore,
});

const result = await executeWithLiveQueries({
  schema,
  document: parse('{ hello }'),
  contextValue: {},
  variableValues: {},
  operationName: null,
});

console.log(result);

Live Query Store

The Live Query Store is used to manage and store live queries. The code sample shows how to create a Live Query Store, add a live query to it, and notify subscribers of changes.

const { LiveQueryStore } = require('@n1ru4l/graphql-live-query');

const liveQueryStore = new LiveQueryStore();

// Add a live query to the store
const queryId = liveQueryStore.add({
  document: parse('{ hello }'),
  variables: {},
  contextValue: {},
  rootValue: {},
  operationName: null,
});

// Notify subscribers of changes
liveQueryStore.invalidate(queryId);

Other packages similar to @n1ru4l/graphql-live-query

Keywords

FAQs

Package last updated on 29 Jul 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc