UNPKG

@cran/gql.reflect

Version:

Cranberry Introspection Utilities for GraphQL

40 lines (27 loc) 757 B
# Cranberry / GQL / Reflect > Introspection Utilities for GraphQL ## Usage ```ts 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. ```ts const reflection = new ReflectSchema(schema, { filter ( type ) { return !(/^_|Query|Mutation|Subscription/).test(type.name); } }); ``` ### Extra Fields > Compatible with `@cran/vue.core` ```ts const { data: { __schema: schema } } = await query(getIntrospectionQuery({ default: [ "title", "color", "icon", ], })); ```