Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

Config

Configuration for graphql.config.ts, exported with defineConfig. The schema and documents keys are compatible with graphql-config, so GraphQL editor extensions can share the file.

Example

import { defineConfig } from "@effect/graphql-generator/Config"
export default defineConfig({
schema: "./schema/github.graphql",
documents: ["src/**\/*.graphql"],
scalars: {
GitObjectID: "effect/Schema#String"
}
})
4 exports Since v4.0.0 Source

Constructors

Types a config file's default export. It returns its argument unchanged.

Signature

declare function defineConfig(config: {
readonly documents: readonly Array<string>;
readonly importExtension?: ".ts" | ".js";
readonly scalars?: {
[key: string]: `${string}#${string}`;
};
readonly schema: string;
readonly shared?: string;
}): {
readonly documents: readonly Array<string>;
readonly importExtension?: ".ts" | ".js";
readonly scalars?: {
[key: string]: `${string}#${string}`;
};
readonly schema: string;
readonly shared?: string;
}

Models

Since v4.0.0

A decoded generator configuration.

Signature

type Config = typeof Config.Type

Schemas

Since v4.0.0

The configuration Schema, used to decode a config file's default export.

  • schema: the SDL (.graphql) or introspection JSON (.json) file, relative to the config file.
  • documents: glob patterns (*, **, ?, {a,b}) for the executable .graphql or .gql documents, relative to the config file. Absolute patterns are a ConfigError, and a { without a closing } is a literal character. node_modules and dot-directories are skipped, and the schema file is never treated as a document.
  • scalars: a Schema codec per custom scalar, also able to override the built-in Int, Float and ID. Custom scalars named DateTime and URI default to Schema.DateTimeUtcFromString and Schema.String; scalars can override them too. Other unmapped custom scalars decode as Schema.Json.
  • shared: where the shared module goes. Defaults to the schema's name and directory, e.g. github.graphql or github.json gives github.graphql.ts. It can't be the schema, a document or a document's output.
  • importExtension: the extension used in imports between generated files and to relative scalar modules. Accepts .ts (default) or .js. A relative scalar module's .ts, .js or missing extension is replaced; any other extension, such as .mjs, is kept.

Signature

declare const Config: Struct<{
readonly documents: $Array<String>;
readonly importExtension: optional<Literals<readonly [".ts", ".js"]>>;
readonly scalars: optional<$Record<String, TemplateLiteral<readonly [String, "#", String]>>>;
readonly schema: String;
readonly shared: optional<String>;
}>

A "<module>#<export>" reference to a Schema codec for a custom scalar. Relative modules resolve against the config file; bare modules are imported as written.

Signature

declare const ScalarSpecifier: TemplateLiteral<readonly [String, "#", String]>