Socket
Socket
Sign inDemoInstall

replit-graphql

Package Overview
Dependencies
4
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    replit-graphql

An easy way to use the replit's graphql API.


Version published
Weekly downloads
37
increased by1133.33%
Maintainers
1
Install size
144 kB
Created
Weekly downloads
 

Readme

Source

Replit GraphQL Client

Replit GraphQL is the most performant, package which interacts with the Replit's GraphQL API to send GraphQL queries, mutations and subscriptions.

Installation

Install it by running this command in the Shell tab of your Repl

npm install replit-graphql

Usage

const replit = require('replit-graphql');

const getUsernameById = `query ($id: Int!) {
	user(id: $id) {
		username
	} 
}`;

const variables = { id: 1 };

replit.query(getUsernameById, { variables }).then(console.log);

API

Replit GraphQL exports an object with the following functions:

function query(query: string, config?: {
	variables?: object|string,
	raw?: boolean
}) => Promise<object|string>

Performs a GraphQL query with the given query and variables. Returns a Promise that resolves to the query result.

function subscribe(query: string, config?: {
	variables?: object|string
}) => EventEmitter

Performs a GraphQL subscription with the given query and variables. It returns an EventEmitter which has the following methods:

  • on(eventName: string, callback)
  • unsubscribe
function setSid(sid: string) => void

Sets the sid which is used for queries and subscriptions. If you have an environment variable/secret called SID, that will be used by default.

Contributing

Contributions are welcome! If you find a bug or want to add a new feature, please open an issue or submit a pull request on the GitHub repository.

Keywords

FAQs

Last updated on 12 Sep 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc