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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aexol/axolotl-core

v2.1.9

Published

Axolotl’s core library. It provides the type-safe, schema-first building blocks used by adapters and apps.

Readme

@aexol/axolotl-core

Axolotl’s core library. It provides the type-safe, schema-first building blocks used by adapters and apps.

  • Axolotl runtime primitives (Axolotl, AxolotlAdapter)
  • Helpers to create resolvers, scalars, directives, and apply middleware
  • Utilities for schema inspection, federation, model generation, and chaos testing

Key APIs

  • Axolotl(adapter)<Models, Scalars, Directives>() – bootstraps a project with a selected adapter
  • createResolvers, createScalars, createDirectives, applyMiddleware – author resolvers and plug middleware
  • setSourceTypeFromResolver – infer source type from a resolver
  • generateModels, inspectResolvers, createSuperGraph, chaos – utilities used by the CLI

See packages/core/index.ts:1 for exports and packages/core/types.ts:1 for types.

When To Use

  • Building GraphQL servers with strong typing over your schema
  • Sharing common logic across adapters (Node.js Yoga, Deno Yoga) and examples

Develop

  • Build: npm run build --ws --if-present
  • Test: npm test
  • Lint: npx eslint packages/core

Minimal Example (with an adapter)

import { Axolotl } from '@aexol/axolotl-core';
import { graphqlYogaAdapter } from '@aexol/axolotl-graphql-yoga';

const { createResolvers } = Axolotl(graphqlYogaAdapter)<{
  Query: { hello: string };
}>();

export const resolvers = createResolvers({
  Query: {
    hello: async () => 'world',
  },
});

Scalars

Axolotl lets you define GraphQL custom scalars in a type‑safe way and pass them to your adapter.

  1. Declare the scalar in your SDL and regenerate models if you use codegen
scalar URL

type Beer {
  url: URL
}
  1. Type your scalar map via the second generic argument to Axolotl and implement with createScalars
import { Axolotl } from '@aexol/axolotl-core';
import { GraphQLScalarType, Kind } from 'graphql';
import { graphqlYogaAdapter } from '@aexol/axolotl-graphql-yoga';

type ScalarModels = { URL: unknown };

const { createScalars, createResolvers } = Axolotl(graphqlYogaAdapter)<
  { Query: { ping: string } },
  ScalarModels
>();

const scalars = createScalars({
  URL: new GraphQLScalarType({
    name: 'URL',
    serialize(value) {
      return new URL(String(value)).toString();
    },
    parseValue(value) {
      return value == null ? value : new URL(String(value));
    },
    parseLiteral(ast) {
      if (ast.kind !== Kind.STRING) return null;
      try {
        return new URL(ast.value);
      } catch {
        return null;
      }
    },
  }),
});

const resolvers = createResolvers({
  Query: { ping: () => 'pong' },
});

// Pass scalars to the adapter alongside resolvers
graphqlYogaAdapter({ resolvers, scalars });

Notes

  • createScalars({...}) is typed: keys must match your ScalarModels keys.
  • Provide at least serialize and parseValue; parseLiteral is recommended for literal input handling.
  • All adapters merge scalars into the executable schema next to your resolvers.

Directives

Axolotl lets adapters apply GraphQL directives by mapping them to field/config transforms.

  • The third generic to Axolotl(...)<Models, Scalars, Directives>() controls the available directive names.
  • Use createDirectives to define mappers. Each directive is an adapter‑specific function that returns a SchemaMapper (see adapter docs).
  • Pass the resulting directives object to your adapter along with resolvers and scalars.

Example (Yoga adapter shown):

import { Axolotl } from '@aexol/axolotl-core';
import { graphqlYogaWithContextAdapter } from '@aexol/axolotl-graphql-yoga';
import { defaultFieldResolver } from 'graphql';
import { MapperKind } from '@graphql-tools/utils';

type DirModels = { auth: { args: Record<string, never> } };

const { createDirectives, createResolvers } = Axolotl(graphqlYogaWithContextAdapter())<
  { Query: { secret: string } },
  {},
  DirModels
>();

const directives = createDirectives({
  auth: (schema, getDirective) => ({
    [MapperKind.OBJECT_FIELD]: (fieldConfig) => {
      const has = getDirective(schema, fieldConfig, 'auth');
      if (!has) return fieldConfig;
      const { resolve = defaultFieldResolver } = fieldConfig as any;
      return {
        ...fieldConfig,
        resolve: async (parent: any, args: any, ctx: any, info: any) => {
          if (!ctx.userId) throw new Error('Not authorized');
          return resolve(parent, args, ctx, info);
        },
      } as any;
    },
  }),
});

const resolvers = createResolvers({
  Query: { secret: () => 'top secret' },
});

// Include directives when creating the server
graphqlYogaWithContextAdapter()({ resolvers, directives });

Notes

  • Directive implementations are adapter‑specific. See adapter READMEs for types and context signatures.