npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@financial-times/n-memb-gql-client

v2.2.4

Published

A tiny wrapper around the FT Membership GraphQL API

Downloads

269

Readme

n-memb-gql-client CircleCI npm version

A tiny wrapper around the membership graph ql api, with some convenient methods.

const membQl = require('@financial-times/n-memb-gql-client');

membQl.canned('user-query', { userId: 'XYZ' })
	.then(res => {
		if (!res._ok) {
			// valid response but contains errors
		}
		// handle response
	})
	.catch(err => {
		// handle error
	});

Usage

Ensure MEMBQL_API_KEY_PROD and MEMBQL_API_ENDPOINT_PROD env variable is set.

By default queries will use production.

You must also set MEMBQL_API_KEY_TEST and MEMBQL_API_ENDPOINT_TEST if you wish to query using the test environment.

Further more you can set MEMBQL_API_KEY_MOCK and MEMBQL_API_ENDPOINT_MOCK if you wish to use a mock mode.

membQl.query(query, variables [, {testMode, mockMode, keepAlive, timeout}])

  • query (string) a raw graph ql query see below.

  • variables (object) contains the variables required for the query.

Options

  • testMode (boolean) default=false whether or not to use the test endpoint and api key.

  • mockMode (boolean) default=false whether or not to use the mock endpoint and api key.

  • keepAlive (boolean) default=true whether or not to keep the connection to the GraphQL API alive.

  • timeout (integer) default=5000 connection timeout cutoff, in ms.

  • overrideHost (string) (optional) an override host to use instead of MEMBQL_API_ENDPOINT_* (remember to include protocol and correct path).

  • apiKeyHeaderName (string) (optional) an override header to use instead of x-api-key (e.g. ft-next-backend-key or ft-api-key).

membQl.canned(queryName, variables [, {testMode, mockMode, keepAlive, timeout}])

  • queryName (string) the canned query name see below.

  • variables (object) contains the variables required for the query.

Options

  • testMode (boolean) default=false whether or not to use the test endpoint and api key.

  • mockMode (boolean) default=false whether or not to use the mock endpoint and api key.

  • keepAlive (boolean) default=true whether or not to keep the connection to the GraphQL API alive.

  • timeout (integer) default=5000 connection timeout cutoff, in ms.

  • overrideHost (string) (optional) an override host to use instead of MEMBQL_API_ENDPOINT_* (remember to include protocol and correct path).

  • apiKeyHeaderName (string) (optional) an override header to use instead of x-api-key (e.g. ft-next-backend-key or ft-api-key).

Canned queries

membQl.canned('user-query', { userId: 'XYZ' });

See docs on canned queries here. Query names can be found here.

Custom queries

const customQuery = `
	query($session: String!) {
		userBySession(session: $session) {
			access {
				isB2c
			}
		}
	}
`;
membQl.query(customQuery, { session: 'XYZ' });