0.1.0 • Published 3 years ago

@cran/gql.reflect v0.1.0

Weekly downloads
-
License
CC-BY-ND-4.0
Repository
-
Last release
3 years ago

Cranberry / GQL / Reflect

Introspection Utilities for GraphQL

Usage

import { ReflectSchema, getIntrospectionQuery } from "@cran/gql.reflect";

(async function main ( ) {
  const { data: { __schema: schema } } = await query(getIntrospectionQuery());

  const reflection = new ReflectSchema(schema);
})();

Filtering

Optionally, the ReflectSchema constructor may take a filter to remove types.

const reflection = new ReflectSchema(schema, {
  filter ( type ) {
    return !(/^_|Query|Mutation|Subscription/).test(type.name);
  }
});

Extra Fields

Compatible with @cran/vue.core

const { data: { __schema: schema } } = await query(getIntrospectionQuery({
  default: [ "title", "color", "icon", ],
}));