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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fejk-ql

v0.3.1

Published

a simple gql mock engine

Readme

CircleCI

fejk-ql

A stateless GraphQL mock with stateful capabilities.

This library serves to act as a mock of one or many GraphQL graphs. It does so by making a small extension to the API of graphql-tools, and adding a cookie-based mechanism for keeping a small state representation on the client.

Table of contents

Why fejk-ql

This library is built with two use cases in mind:

  • Developing a web app that depends on a GraphQL API
  • Testing a web app that depends on a GraphQL API

For development you may or may not have an API available to you. If you have the GraphQL schema setting up a rich mock is simple with fejk-ql.

For testing you might not want to depend on other services than the application you are testing. fejk-ql can be run in the same process as your web app, or side by side, to make application testing without dependencies to other services simple.

How fejk-ql is different from built in graph-ql-tools mocking

This library offers client-driven statefulness and a mock format, and saves you the time to configure graphql-tools yourself. If you're fine with configuring graphql-tools and don't have a need for faking statefulness, this library might not be for you.

Requirements

To use this library:

To develop this library:

Getting started

  • Set up an express server with a body parser and cookie parser of your choice.
  • Add a mock, or default mock - see Mock folder.
  • Designate the mock folder in the environment variable FEJK_QL_MOCK_PATH.
  • (optional) Configure a mock header name - see Specifying a mock in your graphql query
  • Mount the fejk-ql middleware on a path of your choice - e.g. app.use('/gql-mock', fejk-ql);.
  • Start your server and start querying! See Specifying a mock in your graphql query for more info on how to pick a mock per query.

See Running the example for an example and tips for getting started.

Mock folder

fejk-ql supports exactly one mock folder, with no subfolders. The mock folder contains all graph mocks, according to the Mock format. The file name will denote the unique name of your mock, e.g mocks/my-mock.js will be given the unique name my-mock.

When starting your app, the mock folder is designated by the mandatory FEJK_QL_MOCK_PATH env variable.

Specifying a mock in your graphql query

To specify which mock to use when responding to a query, the optional fejk-ql-graph-name can be set to the mocks name. If you want to change the header name, set the environment FEJK_QL_HEADER_NAME to your desired name.

How the graph name is chosen is described in Mock folder.

If the header is not set, a mock named default will be used. If the header is not set and there is no mock named default the service will respond with a 500.

One way of doing this in your client per query is to use the apollo client context

Mock format

The mock format is inspired by the parameters provided when setting up a graphql mock in graphql-tools. A mock file must export a single object with the following fields:

  • typeDefs - the graphql schema string to mock.
  • resolvers - any resolvers to include. May be an empty object.
  • mocks - The mocks to use, according to the format specified in Customizing mocks.
  • deltas - An array of deltas to apply, giving the mock client-driven statefulness. Specifying deltas will allow the mock to respond to the same query in different ways to simulate statefulness. See Deltas for more info.
  • deltasCumulative (optional) - A boolean indicating whether to apply deltas in a cumulative fashion. If true, all deltas up until, and including, the current delta index will be applied before sending the response, instead of only the delta at the delta index.

Deltas

Each delta will override the mocking specified in the mocks field. The deltas will be merged with the mocks, overriding only what you specify in the deltas.

The deltas will be served round-robin, starting at index 0. Once the last delta is served, the mock will serve one delta-free response and then start applyting deltas again.

The delta functionality stores a cookie in the client to indicate which delta to serve next. If the client does not support cookies the initial state will always be served.

Running the example

The example is a separate node project found under /example. To start it:

  • Check out the repo.

In the example folder: