@cran/gql.reflect
Version:
Cranberry Introspection Utilities for GraphQL
40 lines (27 loc) • 757 B
Markdown
> Introspection Utilities for GraphQL
```ts
import { ReflectSchema, getIntrospectionQuery } from "@cran/gql.reflect";
(async function main ( ) {
const { data: { __schema: schema } } = await query(getIntrospectionQuery());
const reflection = new ReflectSchema(schema);
})();
```
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);
}
});
```
> Compatible with `@cran/vue.core`
```ts
const { data: { __schema: schema } } = await query(getIntrospectionQuery({
default: [ "title", "color", "icon", ],
}));
```