--- title: "glink.json Configuration Reference" description: "Every glink.json / glink.yaml option: schemaPaths, typeMappings and scalar codecs, outputDir, clientConfig for seven languages, serverConfig, CLI flags." --- # Configuration Reference Full reference for every option in `glink.json` / `glink.yaml`. ## Top-level options === "JSON" ```json title="glink.json — top-level structure" { "schemaPaths": ["schema/*.graphql"], "mode": "client", "typeMappings": { "ID": "String", "Float": "double" }, "unknownScalarType": "String", "outputDir": "lib/generated", "identityFields": ["id"], "disableCache": false, "clientConfig": { }, "serverConfig": { } } ``` === "YAML" ```yaml title="glink.yaml — top-level structure" schemaPaths: - schema/*.graphql mode: client typeMappings: ID: String Float: double unknownScalarType: String outputDir: lib/generated identityFields: - id disableCache: false clientConfig: # see sections below serverConfig: # see sections below ``` | Option | Type | Default | Description | |---|---|---|---| | `schemaPaths` | `string[]` | — | **Required.** Glob patterns for schema files. Multiple patterns are supported — all matched files are merged into one schema. | | `mode` | `"client"` \| `"server"` | `"server"` | Controls which generator runs. `"client"` generates a typed client (Dart, Java, or TypeScript). `"server"` generates Spring Boot scaffolding. | | `typeMappings` | `Record` | `{}` | Maps GraphQL scalar names to target-language types. Entries here override the defaults. Add entries for custom scalars. An entry can be an object, `{"type", "import", "fromJson", "toJson", "jsonType"}`, to convert the scalar when it is decoded and encoded: `{}` stands for the value, and `jsonType` (`String`, `Int`, `Double`, `Bool`, `Map` or `List`) makes the generated decoder check the JSON type before `fromJson` runs. See "Custom scalar codecs" on each client page. | | `unknownScalarType` | `string` \| `null` | `null` | Fallback target-language type for any custom scalar **not** covered by `typeMappings` or an `@glExternal` directive. Without it, an unmapped `scalar UserId` is emitted verbatim as `UserId`; set e.g. `"String"` (Dart), `"string"` (TypeScript), or `"Object"` (Java) to map all such scalars uniformly. Since one config targets a single language, write the value in that language's type syntax. `typeMappings` and `@glExternal` always take precedence. | | `outputDir` | `string` | `"src/main/java"` | Directory where generated files are written. Existing files are overwritten on every run. | | `identityFields` | `string[]` | `[]` | Field names treated as identity fields when generating `==` / `hashCode` methods (Dart and Java). Fields listed here are always included in equality regardless of `@glEqualsHashcode`. | | `disableCache` | `boolean` | `false` | When `true`, strips all `@glCache` and `@glCacheInvalidate` directives from the generated client — useful for debugging or environments where caching is handled externally. | | `restNullableSuffix` | `string` | `"Rest"` | Suffix of the nullable copy generated for a REST operation marked [`@glRestNullable`](rest-client.md#lenient-responses-glrestnullable) (`Product` gives `ProductRest`). Letters, digits and `_`, not starting with a digit. | | `restNullable` | `boolean` | `false` | When `true`, every REST operation behaves as if it carried [`@glRestNullable`](rest-client.md#lenient-responses-glrestnullable): it returns the nullable copy of its response type. Operations that cannot be copied (text, binary, void, scalar or enum results) are left alone. Turning it on renames result types at call sites (`Product` gives `ProductRest`). | --- ## `clientConfig.dart` Used when `mode` is `"client"` and you want Dart/Flutter output. === "JSON" ```json title="glink.json — clientConfig.dart" { "clientConfig": { "dart": { "packageName": "my_app", "httpAdapter": "http", "generateAdapters": true, "generateAllFieldsFragments": true, "autoGenerateQueries": true, "autoGenerateQueriesDefaultAlias": null, "autoGenerateQueriesFor": null, "autoGenerateQueriesArgumentLimit": 200, "maxFragmentBodySize": 8192, "defaultAlias": null, "operationNameAsParameter": false, "nullableFieldsRequired": false, "immutableInputFields": true, "immutableTypeFields": true, "captureErrors": false, "flutter": { "generateTypes": true, "generateInputs": false, "typesToSkip": [], "inputsToSkip": [], "defaultGap": 16, "booleanWidget": "switchWidget", "nullableBooleanWidget": "checkbox", "listWidget": "chips", "defaultLabelPosition": "floatingLabel", "defaultLabelWidth": 120, "defaultFormLayout": "column", "defaultRequiredIndicator": "asterisk", "defaultDebounceDuration": 300, "defaultStepperOrientation": "vertical", "defaultTypeLayout": "labeledRow", "defaultGroupLayout": "labeledRow", "defaultDatePattern": "yyyy-MM-dd", "defaultDateFirstYear": 1900, "defaultDateLastYear": 2100, "defaultDateMode": "dialog", "sdkVersion": "3.47.5", "designLibrary": "flutter" } } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.dart" clientConfig: dart: packageName: my_app httpAdapter: http generateAdapters: true generateAllFieldsFragments: true autoGenerateQueries: true autoGenerateQueriesDefaultAlias: null autoGenerateQueriesFor: null autoGenerateQueriesArgumentLimit: 200 maxFragmentBodySize: 8192 defaultAlias: null operationNameAsParameter: false nullableFieldsRequired: false immutableInputFields: true immutableTypeFields: true captureErrors: false flutter: generateTypes: true generateInputs: false typesToSkip: [] inputsToSkip: [] defaultGap: 16 booleanWidget: switchWidget nullableBooleanWidget: checkbox listWidget: chips defaultLabelPosition: floatingLabel defaultLabelWidth: 120 defaultFormLayout: column defaultRequiredIndicator: asterisk defaultDebounceDuration: 300 defaultStepperOrientation: vertical defaultTypeLayout: labeledRow defaultGroupLayout: labeledRow defaultDatePattern: "yyyy-MM-dd" defaultDateFirstYear: 1900 defaultDateLastYear: 2100 defaultDateMode: dialog sdkVersion: "3.47.5" designLibrary: flutter ``` | Option | Type | Default | Description | |---|---|---|---| | `packageName` | `string` | — | **Required.** The Dart package name used for import paths in generated files (e.g. `"my_app"` produces `import 'package:my_app/...'`). | | `httpAdapter` | `"http"` \| `"dio"` \| `"none"` | `"http"` | Which HTTP adapter file to generate. `"http"` uses `package:http`. `"dio"` uses Dio (supports interceptors, custom `BaseOptions`). `"none"` skips adapter generation — supply your own `Future Function(String)`. | | `restHttpAdapter` | `"http"` \| `"dio"` \| `"none"` | same as `httpAdapter` | Which adapter to generate for [REST operations](rest-client.md). `"none"` skips it and `withHttp` then takes a `restAdapter` instead of `restBaseUrl`. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How a list of scalars is sent in a REST query string: repeated keys (`a=1&a=2`) or one comma-joined value (`a=1,2`). | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested input objects are keyed in REST query strings, forms and multipart: `a.b` or `a[b]`. | | `generateAdapters` | `boolean` | `true` | When `false`, skips generating the HTTP and WebSocket adapter files. Use this if you maintain your own adapter implementations and don't want them overwritten. | | `generateAllFieldsFragments` | `boolean` | `true` | Generates a `_all_fields_TypeName` named fragment for every type in the schema. Required for `autoGenerateQueries` to work. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation using `_all_fields` fragments. When `true`, you do not need to write any query strings by hand. | | `autoGenerateQueriesDefaultAlias` | `string` \| `null` | `null` | Default alias prefix to use for auto-generated query fields when `autoGenerateQueries` is `true`. Useful when multiple operations select the same root field. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations instead of every root field. Use instead of (or alongside) `autoGenerateQueries` when you only need a subset — e.g. on large schemas. Each key (`queries`, `mutations`, `subscriptions`) takes a list of root field names. Any listed name not found in the schema causes a build error. Requires `generateAllFieldsFragments: true`. See [Selective auto-generation](custom-queries.md#selective-auto-generation-autogeneratequeriesfor). | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `fieldArgs` object of an auto-generated operation. When the limit is exceeded, GraphLink skips the operation and prints a `⚠` warning. Hand-written operations are never affected. Raise the value for unusually large schemas, or write a custom query with a narrower field selection instead. See [Argument limit](custom-queries.md#auto-generated-query-argument-limit). | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Fragments whose serialized body exceeds this limit are silently omitted, and any auto-generated queries that depend on them are also skipped. Set to `null` to disable the cap and always generate all fragments. Useful when `generateAllFieldsFragments: true` is used on a very large schema (e.g. Shopify's) where individual fragment bodies can reach 60 KB+, inflating both the compiled binary and every network request. | | `defaultAlias` | `string` \| `null` | `null` | Default alias applied to all generated query fields globally when no field-level alias is declared. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, the generated HTTP adapter function signature includes a second `operationName` parameter: `Future Function(String payload, String operationName)`. The operation name is appended to the URL as a query parameter, which is useful for server-side logging and APM tracing. | | `nullableFieldsRequired` | `boolean` | `false` | When `true`, nullable fields in generated constructors are emitted as `required this.fieldName` instead of optional `this.fieldName`. Use this to enforce that all fields are always explicitly passed at construction sites. | | `immutableInputFields` | `boolean` | `true` | Input class fields are `final`. Recommended. | | `immutableTypeFields` | `boolean` | `true` | Response type class fields are `final`. Recommended for client-side code. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` behaviour to every query and mutation. Each method returns a `{OperationName}FullResponse` holding nullable `data` and nullable `errors` instead of throwing on GraphQL errors. Equivalent to annotating every query and mutation field with `@glCaptureErrors` in the schema. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `unknownValue__` member, and a value the schema did not declare (for example one added to the server after this client shipped) decodes to it instead of throwing. Encoding it back to the server throws. Set to `true` to throw on unknown values instead. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | | `appLocalizationsImport` | `string` \| `null` | `null` | Import path for an `AppLocalizations` class injected into generated Flutter UI widgets. Only relevant when `flutter` is configured. | | `flutter` | `object` | — | Enables Flutter widget generation and sets project-wide UI defaults. Omit the key entirely to disable Flutter generation. See [`clientConfig.dart.flutter`](#clientconfigdartflutter) for the full sub-key reference. | --- ## `clientConfig.dart.flutter` Flutter widget generation is enabled by adding a `flutter:` block inside `clientConfig.dart`. Omitting the block entirely disables Flutter generation. All keys are optional — unset keys use the built-in default. Keys split into two groups: **generation toggles** (what to generate) and **UI defaults** (what values are baked into generated widget constructors). ### Generation toggles | Option | Type | Default | Description | |---|---|---|---| | `generateTypes` | `boolean` | `true` | Generate stateless display widgets for schema `type` definitions (e.g. `VehicleWidget`). | | `generateInputs` | `boolean` | `false` | Generate stateful form widgets for schema `input` definitions (e.g. `AddVehicleInputForm`). | | `typesToSkip` | `string[]` | `[]` | Type names excluded from display widget generation. | | `inputsToSkip` | `string[]` | `[]` | Input names excluded from form widget generation. | ### Global widget style | Option | Type | Default | Description | |---|---|---|---| | `defaultGap` | `number` | `16` | Default spacing (dp) between rows in every generated widget and form. | | `booleanWidget` | `"switchWidget"` \| `"checkbox"` \| `"tristate"` | `"switchWidget"` | Default widget for non-nullable `Boolean` fields. `switchWidget` → `Switch`/`SwitchListTile`. `checkbox` → `Checkbox`. `tristate` → Yes/No/— dropdown. | | `nullableBooleanWidget` | `"checkbox"` \| `"tristate"` | `"checkbox"` | Default widget for nullable `Boolean?` fields. `switchWidget` is excluded — `Switch` cannot represent `null`. | | `listWidget` | `"chips"` \| `"checkboxes"` | `"chips"` | Default widget for enum-list and scalar-list fields. | ### Input form defaults These values are emitted as the default constructor parameter values in every generated form widget. They can be overridden per widget call site at runtime. | Option | Type | Default | Description | |---|---|---|---| | `defaultLabelPosition` | `"floatingLabel"` \| `"beside"` \| `"above"` | `"floatingLabel"` | Default label position across all generated forms. | | `defaultLabelWidth` | `number` | `120` | Default width (dp) of the label column in `beside` mode. | | `defaultFormLayout` | `"column"` \| `"twoColumn"` | `"column"` | Default layout for all generated forms. | | `defaultRequiredIndicator` | `"asterisk"` \| `"none"` \| `"requiredText"` \| `"optionalText"` | `"asterisk"` | Default required-field indicator style. | | `defaultDebounceDuration` | `number` | `300` | Milliseconds to wait after the last field change before firing `onChange`. | | `defaultStepperOrientation` | `"vertical"` \| `"horizontal"` | `"vertical"` | Default Flutter `StepperType` for forms that use the stepper layout (inputs with nested input fields). | ### Type display widget defaults | Option | Type | Default | Description | |---|---|---|---| | `defaultTypeLayout` | `"labeledRow"` \| `"listTile"` \| `"listTileReversed"` \| `"expandable"` | `"labeledRow"` | Default layout for all generated display widgets. | | `defaultGroupLayout` | `"labeledRow"` \| `"listTile"` \| `"listTileReversed"` | `"labeledRow"` | Default layout of the scalar accordion group inside the `expandable` layout. | ### Date picker defaults These values are baked into the generated `DateInputConfig` class defaults and into every generated date-picker helper. Per-field `DateInputConfig` values always take precedence. | Option | Type | Default | Description | |---|---|---|---| | `defaultDatePattern` | `string` | `"yyyy-MM-dd"` | Default `pattern` in the generated `DateInputConfig` class. Use `"dd/MM/yyyy"`, `"MM/dd/yyyy"`, etc. to match your locale. | | `defaultDateFirstYear` | `number` | `1900` | Fallback `firstDate` year used by all generated date pickers when no `firstDate` is provided in `DateInputConfig`. | | `defaultDateLastYear` | `number` | `2100` | Fallback `lastDate` year used by all generated date pickers when no `lastDate` is provided in `DateInputConfig`. | | `defaultDateMode` | `"dialog"` \| `"inline"` | `"dialog"` | Default `DateInputMode` in the generated `DateInputConfig` class. | | `defaultDecimalSeparator` | `"either"` \| `"dot"` \| `"comma"` | `"either"` | Default `decimalSeparator` of the generated `NumberInputConfig`, which every `int` and `double` field of a form uses. `either` accepts one `.` or one `,` as the decimal separator and never accepts a grouping character, so `3,14` is always 3.14. Override per field with the form's `numberConfig`. | | `defaultClearButton` | `boolean` | `false` | Show a clear (X) button on generated text fields. Override per field with `TextFieldOptions(clearButton: true/false)` in the form's `TextConfig`. Hidden while the field is empty or disabled, replaced by the spinner during async validation, and never shown on password fields. The tooltip comes from `FormStrings.clear`. | | `persistDrafts` | `boolean` | `false` | Generate draft persistence for the forms. Each form gets optional `draftStore` (a `FormDraftStore` you implement over SharedPreferences, a file, your backend, …) and `draftId` parameters. While a store is set, the form is disabled until its saved draft is restored, then saves field values (debounced, and flushed on dispose) under `graphlink_generated_form_` (suffixed with `:` when given). Password-like fields are never saved. A draft saved by a different version of the input is discarded. A full `reset()` deletes the draft; delete it yourself after a successful submit with `store.delete(MyInputForm.draftKeyFor(id))`. Fields replaced through `Values` are saved via `read()` and restored via `InputFormState.restore(value)`, which does nothing unless your widget overrides it. | | `sdkVersion` | `string` | _(unset)_ | Flutter version the generated widgets target, e.g. `"3.47.5"`. From `3.35` on, generated forms use `RadioGroup` instead of the deprecated `RadioListTile.groupValue`/`onChanged`, and `DropdownButtonFormField(initialValue:)` instead of `value:`. When unset, the pre-3.35 API is generated, which works on any SDK but reports deprecation warnings on newer ones. **Quote the value** in YAML: an unquoted `3.10` is read as the number `3.1`. | | `designLibrary` | `"flutter"` \| `"standalone"` | `"flutter"` | Which Material/Cupertino library generated files import. `"flutter"` uses `package:flutter/material.dart` and `cupertino.dart`; `"standalone"` uses `package:material_ui/material_ui.dart` and `package:cupertino_ui/cupertino_ui.dart` (Flutter 3.47+, add both packages to your `pubspec.yaml`). It must match the library your app uses, because generated types such as `TextFieldOptions` expose Material types. | --- ## `clientConfig.java` Used when `mode` is `"client"` and you want a Java client. === "JSON" ```json title="glink.json — clientConfig.java" { "clientConfig": { "java": { "packageName": "com.example.generated", "wsAdapter": "java11", "jsonCodec": "jackson", "generateAllFieldsFragments": true, "autoGenerateQueries": true, "autoGenerateQueriesFor": null, "autoGenerateQueriesArgumentLimit": 200, "maxFragmentBodySize": 8192, "defaultAlias": null, "operationNameAsParameter": false, "nullableFieldsRequired": false, "immutableInputFields": true, "immutableTypeFields": true, "inputAsRecord": false, "typeAsRecord": false, "jspecify": false, "asyncStyle": "blocking", "reactiveHttpClient": "jdk", "captureErrors": false } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.java" clientConfig: java: packageName: com.example.generated wsAdapter: java11 jsonCodec: jackson generateAllFieldsFragments: true autoGenerateQueries: true autoGenerateQueriesFor: null autoGenerateQueriesArgumentLimit: 200 maxFragmentBodySize: 8192 defaultAlias: null operationNameAsParameter: false nullableFieldsRequired: false immutableInputFields: true immutableTypeFields: true inputAsRecord: false typeAsRecord: false jspecify: false asyncStyle: blocking reactiveHttpClient: jdk captureErrors: false ``` | Option | Type | Default | Description | |---|---|---|---| | `packageName` | `string` | — | **Required.** Java package name for generated files (e.g. `"com.example.generated"`). | | `wsAdapter` | `"java11"` \| `"okhttp"` \| `"none"` | `"java11"` | Which WebSocket adapter to generate. `"java11"` uses `java.net.http.WebSocket` (zero extra dependencies). `"okhttp"` uses OkHttp's WebSocket client. `"none"` skips WebSocket adapter generation. | | `jsonCodec` | `"jackson"` \| `"gson"` \| `"none"` | `"jackson"` | Which JSON codec helper to generate. `"jackson"` generates `JacksonGraphLinkJsonCodec`. `"gson"` generates `GsonGraphLinkJsonCodec`. `"none"` skips codec generation — supply your own lambdas. | | `generateAllFieldsFragments` | `boolean` | `true` | Generates `_all_fields_TypeName` fragments for every type. Required for `autoGenerateQueries` and `autoGenerateQueriesFor`. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations. Keys: `queries`, `mutations`, `subscriptions` — each takes a list of root field names. Unknown names cause a build error. Requires `generateAllFieldsFragments: true`. See [Selective auto-generation](custom-queries.md#selective-auto-generation-autogeneratequeriesfor). | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `fieldArgs` object of an auto-generated operation. When exceeded, GraphLink skips the operation and prints a `⚠` warning. Hand-written operations are never affected. See [Argument limit](custom-queries.md#auto-generated-query-argument-limit). | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Fragments whose body exceeds this limit are silently omitted, and any auto-generated queries that depend on them are also skipped. Set to `null` to disable the cap. | | `defaultAlias` | `string` \| `null` | `null` | Default alias applied to all generated query fields globally. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, the adapter interface includes an `operationName` parameter and the generated client appends it to the request URL as a query parameter. | | `nullableFieldsRequired` | `boolean` | `false` | When `true`, the generated input constructors do not accept `null` for nullable fields — `Objects.requireNonNull` is emitted for all fields. | | `immutableInputFields` | `boolean` | `true` | Input class fields are `private final`. Inputs use builder pattern. | | `immutableTypeFields` | `boolean` | `true` | Response type fields are `private final` with only getters. Recommended for client-side. | | `inputAsRecord` | `boolean` | `false` | Generates input types as Java records instead of classes with builders. Records use component accessor syntax (`field()`) instead of getters (`getField()`). Requires Java 16+. | | `typeAsRecord` | `boolean` | `false` | Generates response types as Java records. Affects how `fromJson` and mapping methods access fields. Requires Java 16+. | | `jspecify` | `boolean` | `false` | Adds `@NonNull` / `@Nullable` from `org.jspecify.annotations` to all generated type, input, and interface fields. Imports are only emitted when enabled. | | `asyncStyle` | `"blocking"` \| `"reactor"` \| `"rxjava3"` \| `"mutiny"` | `"blocking"` | Wraps query/mutation results in the library's deferred-single type (`Mono`/`Single`/`Uni`) and subscriptions in the deferred-many type (`Flux`/`Observable`/`Multi`). `"blocking"` keeps the pre-v5.0.0 direct-return / listener-callback client. See [Reactive client](java-client.md#reactive-client-v500). | | `reactiveHttpClient` | `"jdk"` \| `"webclient"` | `"jdk"` | Transport used by the default adapter under a non-blocking `asyncStyle`. `"jdk"` uses `HttpClient.sendAsync` (works with every `asyncStyle`). `"webclient"` uses Spring `WebClient` (`asyncStyle: "reactor"` only). It applies to the REST adapter as well as the GraphQL one. | | `restHttpAdapter` | `"jdk"` \| `"none"` | `"jdk"` | Whether to generate the JDK `HttpClient` adapter for [REST operations](rest-client.md#java). `"none"` skips it and the factories take a `GLRestAdapter` instead of `restBaseUrl`. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How a list of scalars is sent in a REST query string: repeated keys (`a=1&a=2`) or one comma-joined value. | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested input objects are keyed in REST query strings, forms and multipart: `a.b` or `a[b]`. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` behaviour to every query and mutation. Each method returns a `{OperationName}FullResponse` holding nullable `data` and nullable `errors` instead of throwing on GraphQL errors. Equivalent to annotating every query and mutation field with `@glCaptureErrors` in the schema. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `unknownValue__` member, and a value the schema did not declare (for example one added to the server after this client shipped) decodes to it instead of throwing. Encoding it back to the server throws. Set to `true` to throw on unknown values instead. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | --- ## `clientConfig.typescript` Used when `mode` is `"client"` and you want TypeScript output. === "JSON" ```json title="glink.json — clientConfig.typescript" { "clientConfig": { "typescript": { "httpAdapter": "fetch", "generateDefaultWsAdapter": true, "observables": false, "generateAllFieldsFragments": true, "autoGenerateQueries": true, "autoGenerateQueriesFor": null, "autoGenerateQueriesArgumentLimit": 200, "maxFragmentBodySize": 8192, "defaultAlias": null, "operationNameAsParameter": false, "optionalNullableInputFields": true, "immutableTypeFields": true, "captureErrors": false } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.typescript" clientConfig: typescript: httpAdapter: fetch generateDefaultWsAdapter: true observables: false generateAllFieldsFragments: true autoGenerateQueries: true autoGenerateQueriesFor: null autoGenerateQueriesArgumentLimit: 200 maxFragmentBodySize: 8192 defaultAlias: null operationNameAsParameter: false optionalNullableInputFields: true immutableTypeFields: true captureErrors: false ``` | Option | Type | Default | Description | |---|---|---|---| | `httpAdapter` | `"fetch"` \| `"axios"` \| `"none"` | `"fetch"` | Which HTTP adapter to generate. `"fetch"` uses the native Fetch API (works in Angular, React, Vue, Svelte, Node 18+). `"axios"` uses Axios. `"none"` skips adapter generation. | | `generateDefaultWsAdapter` | `boolean` | `true` | When `true`, generates `DefaultGraphLinkWebSocketAdapter` implementing the graphql-ws protocol with exponential-backoff reconnect. Set to `false` if you have no subscriptions or supply your own adapter. | | `restHttpAdapter` | `"fetch"` \| `"axios"` \| `"none"` | same as `httpAdapter` | Which adapter to generate for [REST operations](rest-client.md). `"none"` skips it; pass your own `GLRestAdapter` to the client. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How a list of scalars is sent in a REST query string: repeated keys (`a=1&a=2`) or one comma-joined value (`a=1,2`). | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested input objects are keyed in REST query strings, forms and multipart: `a.b` or `a[b]`. | | `observables` | `boolean` | `false` | When `true`, query and mutation methods return `Observable` (RxJS) instead of `Promise`. Subscription methods also return `Observable`. Recommended for Angular projects. | | `generateAllFieldsFragments` | `boolean` | `true` | Generates `_all_fields_TypeName` fragments for every type. Required for `autoGenerateQueries` and `autoGenerateQueriesFor`. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation using `_all_fields` fragments. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations. Keys: `queries`, `mutations`, `subscriptions` — each takes a list of root field names. Unknown names cause a build error. Requires `generateAllFieldsFragments: true`. See [Selective auto-generation](custom-queries.md#selective-auto-generation-autogeneratequeriesfor). | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `fieldArgs` object of an auto-generated operation. When exceeded, GraphLink skips the operation and prints a `⚠` warning. Hand-written operations are never affected. See [Argument limit](custom-queries.md#auto-generated-query-argument-limit). | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Fragments whose body exceeds this limit are silently omitted, and any auto-generated queries that depend on them are also skipped. Set to `null` to disable the cap. | | `defaultAlias` | `string` \| `null` | `null` | Default alias applied to all generated query fields globally. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, the adapter function signature includes an `operationName` parameter and the client appends it to the request URL. | | `optionalNullableInputFields` | `boolean` | `true` | When `true`, nullable fields in generated input interfaces use `field?: T \| null` (TypeScript optional property). When `false`, they use `field: T \| null` (required but nullable). | | `immutableTypeFields` | `boolean` | `true` | When `true`, generated type interfaces use `readonly` on all fields. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` behaviour to every query and mutation. Each method returns a `{OperationName}FullResponse` holding optional `data` and optional `errors` instead of throwing on GraphQL errors. Equivalent to annotating every query and mutation field with `@glCaptureErrors` in the schema. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `unknownValue__` member, and a value the schema did not declare (for example one added to the server after this client shipped) decodes to it instead of throwing. Encoding it back to the server throws. Set to `true` to throw on unknown values instead. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | --- ## `clientConfig.kotlin` Used when `mode` is `"client"` and you want Kotlin output. === "JSON" ```json title="glink.json — clientConfig.kotlin" { "clientConfig": { "kotlin": { "packageName": "com.example.generated", "generateAllFieldsFragments": true, "autoGenerateQueries": true, "autoGenerateQueriesFor": null, "autoGenerateQueriesArgumentLimit": 200, "maxFragmentBodySize": 8192, "typeAsDataClass": true, "inputAsDataClass": true, "nullableFieldsRequired": false, "immutableTypeFields": true, "operationNameAsParameter": false, "captureErrors": false, "wsAdapter": "okhttp", "defaultAlias": null } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.kotlin" clientConfig: kotlin: packageName: com.example.generated generateAllFieldsFragments: true autoGenerateQueries: true autoGenerateQueriesFor: null autoGenerateQueriesArgumentLimit: 200 maxFragmentBodySize: 8192 typeAsDataClass: true inputAsDataClass: true nullableFieldsRequired: false immutableTypeFields: true operationNameAsParameter: false captureErrors: false wsAdapter: okhttp defaultAlias: null ``` | Option | Type | Default | Description | |---|---|---|---| | `packageName` | `string` | — | **Required.** Kotlin package name for all generated files. | | `generateAllFieldsFragments` | `boolean` | `true` | Generates `_all_fields_TypeName` fragments for every type. Required for `autoGenerateQueries` and `autoGenerateQueriesFor`. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation using `_all_fields` fragments. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations. Keys: `queries`, `mutations`, `subscriptions` — each takes a list of root field names. Unknown names cause a build error. Requires `generateAllFieldsFragments: true`. See [Selective auto-generation](custom-queries.md#selective-auto-generation-autogeneratequeriesfor). | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `fieldArgs` object of an auto-generated operation. When exceeded, GraphLink skips the operation and prints a `⚠` warning. Hand-written operations are never affected. See [Argument limit](custom-queries.md#auto-generated-query-argument-limit). | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Fragments whose body exceeds this limit are silently omitted, and any auto-generated queries that depend on them are also skipped. Set to `null` to disable the cap. | | `typeAsDataClass` | `boolean` | `true` | Emit output types as `data class`. When `false`, uses `open class`. | | `inputAsDataClass` | `boolean` | `true` | Emit input types as `data class`. When `false`, uses `open class`. | | `nullableFieldsRequired` | `boolean` | `false` | When `true`, nullable constructor parameters have no default — callers must pass them explicitly. | | `immutableTypeFields` | `boolean` | `true` | Generate `val` (immutable) fields instead of `var`. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, appends the operation name as a `?operationName=` query parameter in the HTTP request URL. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` to every query and mutation. Each method returns a `{OperationName}FullResponse` with `data` and `errors` instead of throwing. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `unknownValue__` member, and a value the schema did not declare (for example one added to the server after this client shipped) decodes to it instead of throwing. Encoding it back to the server throws. Set to `true` to throw on unknown values instead. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | | `wsAdapter` | `"okhttp"` \| `"none"` | `"okhttp"` | WebSocket adapter to generate. `"okhttp"` emits `DefaultGraphLinkWebSocketAdapter` using OkHttp; `"none"` emits only the `GraphLinkWebSocketAdapter` interface. | | `restHttpAdapter` | `"okhttp"` \| `"none"` | same as `wsAdapter` | Whether to generate the OkHttp adapter for [REST operations](rest-client.md). `"none"` makes the `create` factories take a `restAdapter` instead of `restBaseUrl`. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How a list of scalars is sent in a REST query string: repeated keys (`a=1&a=2`) or one comma-joined value (`a=1,2`). | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested input objects are keyed in REST query strings, forms and multipart: `a.b` or `a[b]`. | | `defaultAlias` | `string?` | `null` | Default alias applied to all generated query fields globally. | --- ## `clientConfig.swift` Used when `mode` is `"client"` and you want Swift output. See the [Swift Client](swift-client.md) page for a full walkthrough. === "JSON" ```json title="glink.json — clientConfig.swift" { "clientConfig": { "swift": { "moduleName": "GraphLinkGenerated", "generateAllFieldsFragments": true, "autoGenerateQueries": true, "autoGenerateQueriesFor": null, "autoGenerateQueriesArgumentLimit": 200, "maxFragmentBodySize": 8192, "nullableFieldsRequired": false, "immutableTypeFields": true, "operationNameAsParameter": false, "captureErrors": false, "wsAdapter": "urlsession", "defaultAlias": null } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.swift" clientConfig: swift: moduleName: GraphLinkGenerated generateAllFieldsFragments: true autoGenerateQueries: true autoGenerateQueriesFor: null autoGenerateQueriesArgumentLimit: 200 maxFragmentBodySize: 8192 nullableFieldsRequired: false immutableTypeFields: true operationNameAsParameter: false captureErrors: false wsAdapter: urlsession defaultAlias: null ``` | Option | Type | Default | Description | |---|---|---|---| | `moduleName` | `string` | — | **Required.** Used in doc comments / generated `Package.swift` (if emitted) — generated files have no module declaration of their own. | | `generateAllFieldsFragments` | `boolean` | `true` | Generates `_all_fields_TypeName` fragments for every type. Required for `autoGenerateQueries` and `autoGenerateQueriesFor`. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation using `_all_fields` fragments. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations. Keys: `queries`, `mutations`, `subscriptions` — each takes a list of root field names. Unknown names cause a build error. Requires `generateAllFieldsFragments: true`. See [Selective auto-generation](custom-queries.md#selective-auto-generation-autogeneratequeriesfor). | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `fieldArgs` object of an auto-generated operation. When exceeded, GraphLink skips the operation and prints a `⚠` warning. Hand-written operations are never affected. See [Argument limit](custom-queries.md#auto-generated-query-argument-limit). | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Fragments whose body exceeds this limit are silently omitted, and any auto-generated queries that depend on them are also skipped. Set to `null` to disable the cap. | | `nullableFieldsRequired` | `boolean` | `false` | When `true`, nullable initializer parameters have no default — callers must pass them explicitly. | | `immutableTypeFields` | `boolean` | `true` | Generate `let` (immutable) fields instead of `var`. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, appends the operation name as a `?operationName=` query parameter in the HTTP request URL. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` to every query and mutation. Each method returns a `{OperationName}FullResponse` with optional `data` and optional `errors` instead of throwing. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `unknownValue__` member, and a value the schema did not declare (for example one added to the server after this client shipped) decodes to it instead of throwing. Encoding it back to the server sends the literal string `unknownValue__` and the server rejects it (Swift `toJson()` cannot throw; see [Swift enums](swift-client.md#unknown-enum-values)). Set to `true` to throw on unknown values instead. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | | `wsAdapter` | `"urlsession"` \| `"none"` | `"urlsession"` | WebSocket adapter to generate. `"urlsession"` emits `DefaultGraphLinkURLSessionWebSocketAdapter` built on `URLSessionWebSocketTask` (Foundation, no extra dependency); `"none"` emits only the `GraphLinkClientAdapter`/WebSocket typealiases. There is no HTTP-adapter enum for Swift — `URLSession` is part of Foundation on every Apple platform plus Linux, so there's nothing to choose between. | | `restHttpAdapter` | `"urlsession"` \| `"none"` | same as `wsAdapter` | Whether to generate the URLSession adapter for [REST operations](rest-client.md). `"none"` makes `create` take a `restAdapter` instead of `restBaseUrl`. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How list values are written in REST query strings and forms. | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested objects are named in REST query strings, forms and multipart parts. | | `defaultAlias` | `string?` | `null` | Default alias applied to all generated query fields globally. | --- ## `clientConfig.python` Used when `mode` is `"client"` and you want Python output. See the [Python Client](python-client.md) page for a full walkthrough. === "JSON" ```json title="glink.json — clientConfig.python" { "clientConfig": { "python": { "generateAllFieldsFragments": true, "autoGenerateQueries": true, "nullableFieldsRequired": false, "immutableTypeFields": true, "operationNameAsParameter": false, "captureErrors": false, "httpAdapter": "httpx", "wsAdapter": "websockets", "defaultAlias": null } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.python" clientConfig: python: generateAllFieldsFragments: true autoGenerateQueries: true nullableFieldsRequired: false immutableTypeFields: true operationNameAsParameter: false captureErrors: false httpAdapter: httpx wsAdapter: websockets defaultAlias: null ``` | Option | Type | Default | Description | |---|---|---|---| | `generateAllFieldsFragments` | `boolean` | `true` | Generates `_all_fields_TypeName` fragments for every type. Required for `autoGenerateQueries` and `autoGenerateQueriesFor`. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation using `_all_fields` fragments. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations. Keys: `queries`, `mutations`, `subscriptions` — each takes a list of root field names. Unknown names cause a build error. Requires `generateAllFieldsFragments: true`. | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `field_args` object of an auto-generated operation. When exceeded, GraphLink skips the operation and prints a `⚠` warning. | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Larger fragments are omitted, and auto-generated queries that depend on them are skipped. | | `nullableFieldsRequired` | `boolean` | `false` | When `true`, nullable fields have no `None` default — callers must pass them explicitly. | | `immutableTypeFields` | `boolean` | `true` | Generate frozen pydantic models (`ConfigDict(frozen=True)`). Set to `false` for mutable models. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, adapters receive the operation name as a second argument and the default httpx adapter appends it as `?operationName=`. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` to every query and mutation. Each method returns a `{OperationName}FullResponse` with optional `data` and optional `errors` instead of raising `GraphLinkException`. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `unknownValue__` member and a value the schema did not declare decodes to it instead of raising. Encoding it back raises `ValueError`. Set to `true` to raise on unknown values. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | | `httpAdapter` | `"httpx"` \| `"none"` | `"httpx"` | HTTP adapter to generate. `"httpx"` emits `GraphLinkHttpxAdapter` and `GraphLinkClient.with_http(...)`; `"none"` emits only the client, so you pass your own `adapter`. | | `wsAdapter` | `"websockets"` \| `"none"` | `"websockets"` | WebSocket adapter to generate. `"websockets"` emits `DefaultGraphLinkWebSocketAdapter` built on the `websockets` library; `"none"` leaves you to implement `GraphLinkWebSocketAdapter`. | | `restHttpAdapter` | `"httpx"` \| `"none"` | same as `httpAdapter` | Whether to generate the httpx adapter for [REST operations](rest-client.md). `"none"` makes `with_http` take a `rest_adapter` instead of `rest_base_url`. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How list values are written in REST query strings and forms. | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested objects are named in REST query strings, forms and multipart parts: `a.b` or `a[b]`. | | `defaultAlias` | `string?` | `null` | Default alias applied to all generated query fields globally. | --- ## `clientConfig.go` Used when `mode` is `"client"` and you want Go output. See the [Go Client](go-client.md) page for a full walkthrough. === "JSON" ```json title="glink.json — clientConfig.go" { "clientConfig": { "go": { "packageName": "graphql", "generateAllFieldsFragments": true, "autoGenerateQueries": true, "operationNameAsParameter": false, "captureErrors": false, "httpAdapter": "nethttp", "wsAdapter": "coder", "defaultAlias": null } } } ``` === "YAML" ```yaml title="glink.yaml — clientConfig.go" clientConfig: go: packageName: graphql generateAllFieldsFragments: true autoGenerateQueries: true operationNameAsParameter: false captureErrors: false httpAdapter: nethttp wsAdapter: coder defaultAlias: null ``` | Option | Type | Default | Description | |---|---|---|---| | `packageName` | `string` | `"graphlink"` | Go package name written at the top of every generated file. Everything is generated into this one package. | | `generateAllFieldsFragments` | `boolean` | `true` | Generates `_all_fields_TypeName` fragments for every type. Required for `autoGenerateQueries` and `autoGenerateQueriesFor`. | | `autoGenerateQueries` | `boolean` | `true` | Automatically builds query strings for every operation using `_all_fields` fragments. | | `autoGenerateQueriesFor` | `object` \| `null` | `null` | Generates client methods only for the listed operations. Keys: `queries`, `mutations`, `subscriptions` — each takes a list of root field names. Unknown names cause a build error. Requires `generateAllFieldsFragments: true`. | | `autoGenerateQueriesArgumentLimit` | `integer` \| `null` | `200` | Maximum number of propagated (nested-field) arguments allowed in the synthesized `FieldArgs` struct of an auto-generated operation. When exceeded, GraphLink skips the operation and prints a `⚠` warning. | | `maxFragmentBodySize` | `integer` \| `null` | `8192` | Maximum number of characters allowed in the serialized body of a generated `_all_fields` fragment. Larger fragments are omitted, and auto-generated queries that depend on them are skipped. | | `operationNameAsParameter` | `boolean` | `false` | When `true`, adapters receive the operation name as a third argument and the default `net/http` adapter appends it as `?operationName=`. | | `captureErrors` | `boolean` | `false` | When `true`, applies `@glCaptureErrors` to every query and mutation. Each method returns a `{OperationName}FullResponse` with `Data` and `Errors` instead of returning a `*GraphLinkException`. | | `strictEnums` | `boolean` | `false` | When `false`, every generated enum gets an extra `UnknownValue__` constant and a value the schema did not declare decodes to it instead of failing. Encoding it back is an error. Set to `true` to fail on unknown values. | | `persistedQueries` | `false` \| `"apq"` | `false` | `"apq"` sends a SHA-256 hash instead of long queries and retries once with the text on `PersistedQueryNotFound`. See [Persisted Queries](persisted-queries.md). | | `persistedQueriesUseGet` | `boolean` | `false` | Send hash-only queries over GET. Requires `persistedQueries: "apq"`. Mutations always use POST. | | `httpAdapter` | `"nethttp"` \| `"none"` | `"nethttp"` | HTTP adapter to generate. `"nethttp"` emits `GraphLinkHttpAdapter` and `NewGraphLinkClientWithHttp(...)`; `"none"` emits only the client, so you pass your own `Adapter`. | | `wsAdapter` | `"coder"` \| `"none"` | `"coder"` | WebSocket adapter to generate. `"coder"` emits `DefaultGraphLinkWebSocketAdapter` built on `github.com/coder/websocket`; `"none"` leaves you to implement `GraphLinkWebSocketAdapter` and keeps the package free of third-party imports. | | `restHttpAdapter` | `"nethttp"` \| `"none"` | same as `httpAdapter` | Whether to generate the `net/http` adapter for [REST operations](rest-client.md). `"none"` makes `GraphLinkHttpOptions` take a `RestAdapter` instead of `RestBaseURL`. | | `queryListStyle` | `"REPEAT"` \| `"COMMA"` | `"REPEAT"` | How list values are written in REST query strings and forms. | | `formNesting` | `"DOT"` \| `"BRACKET"` | `"DOT"` | How nested objects are named in REST query strings, forms and multipart parts. | | `defaultAlias` | `string?` | `null` | Default alias applied to all generated query fields globally. | `nullableFieldsRequired` and `immutableTypeFields` are accepted for compatibility but have no effect: Go has no optional-by-default fields and no immutable structs. --- ## `serverConfig.spring` Used when `mode` is `"server"`. === "JSON" ```json title="glink.json — serverConfig.spring" { "serverConfig": { "spring": { "basePackage": "com.example.generated", "generateControllers": true, "generateRepositories": false, "immutableInputFields": true, "immutableTypeFields": false, "inputAsRecord": false, "typeAsRecord": false, "reactive": false, "useSpringSecurity": false, "injectDataFetching": false, "generateSchema": false, "schemaTargetPath": null } } } ``` === "YAML" ```yaml title="glink.yaml — serverConfig.spring" serverConfig: spring: basePackage: com.example.generated generateControllers: true generateRepositories: false immutableInputFields: true immutableTypeFields: false inputAsRecord: false typeAsRecord: false reactive: false useSpringSecurity: false injectDataFetching: false generateSchema: false schemaTargetPath: null ``` | Option | Type | Default | Description | |---|---|---|---| | `basePackage` | `string` | — | **Required.** Java package name for all generated classes (e.g. `"com.example.generated"`). | | `generateControllers` | `boolean` | `true` | Generates `@Controller` classes with `@QueryMapping`, `@MutationMapping`, `@SubscriptionMapping`, and `@Argument` on parameters. | | `generateRepositories` | `boolean` | `false` | Generates JPA `Repository` interfaces for types annotated with `@glRepository`. | | `immutableInputFields` | `boolean` | `true` | Input class fields are `private final`. Recommended. | | `immutableTypeFields` | `boolean` | `false` | Type class fields are `private final`. Set to `false` for Spring Boot — Spring's runtime sets fields via setters or reflection. | | `inputAsRecord` | `boolean` | `false` | Generates input types as Java records. Requires Java 16+. | | `typeAsRecord` | `boolean` | `false` | Generates type classes as Java records. Requires Java 16+. | | `reactive` | `boolean` | `false` | When `true`, generates Spring WebFlux-style controllers. Queries and mutations return `Mono`. File upload fields use `FilePart`. | | `useSpringSecurity` | `boolean` | `false` | MVC mode only. Captures the `SecurityContext` before entering `CompletableFuture` lambdas and restores it on the worker thread. Requires `spring-security` on the classpath. Has no effect in reactive mode. | | `injectDataFetching` | `boolean` | `false` | When `true`, generates data-fetching injection code in controllers for field-level resolution. | | `generateSchema` | `boolean` | `false` | When `true`, writes a copy of the processed schema to disk alongside the generated Java. Requires `schemaTargetPath`. | | `schemaTargetPath` | `string` \| `null` | `null` | Path where the schema file is written when `generateSchema` is `true`. Must end in `.graphql` or `.graphqls`. Example: `"src/main/resources/schema.graphqls"`. | !!! info "Strict by default" Since v5.0.0, generated server types enforce real schema nullability by default, and controllers serialize responses to a `Map` via `toJson()`. See [Strict server generation](spring-server.md#strict-server-generation), and the `@glServerLenient` directive in the [Directives reference](directives.md). --- ## `serverConfig.kotlinSpring` Used when `mode` is `"server"` and you want a Kotlin Spring server instead of Java. See [Kotlin Spring Boot server](spring-server.md#kotlin-spring-boot-server) for the full walkthrough. === "JSON" ```json title="glink.json — serverConfig.kotlinSpring" { "serverConfig": { "kotlinSpring": { "basePackage": "com.example.generated", "typeAsDataClass": true, "inputAsDataClass": true, "blockingServices": true, "generateControllers": true, "generateRepositories": false, "immutableInputFields": true, "immutableTypeFields": false, "generateSchema": false, "schemaTargetPath": null } } } ``` === "YAML" ```yaml title="glink.yaml — serverConfig.kotlinSpring" serverConfig: kotlinSpring: basePackage: com.example.generated typeAsDataClass: true inputAsDataClass: true blockingServices: true generateControllers: true generateRepositories: false immutableInputFields: true immutableTypeFields: false generateSchema: false schemaTargetPath: null ``` | Option | Type | Default | Description | |---|---|---|---| | `basePackage` | `string` | — | **Required.** Kotlin package name for all generated files. | | `typeAsDataClass` | `boolean` | `false` | Emit output types as `data class`. When `false`, uses `open class`. | | `inputAsDataClass` | `boolean` | `false` | Emit input types as `data class`. When `false`, uses `open class`. | | `blockingServices` | `boolean` | `true` | Wraps each generated controller's service call in `withContext(Dispatchers.IO + SecurityCoroutineContext()) { ... }`. Set `false` for a coroutine-native, non-blocking service layer. | The remaining options (`generateControllers`, `generateRepositories`, `immutableInputFields`, `immutableTypeFields`, `generateSchema`, `schemaTargetPath`) behave the same as their `serverConfig.spring` equivalents above. --- ## Identifier normalization Since v5.0.0, every generated identifier — field names, argument names, enum values, and type/input/interface/union/enum names — is unconditionally rewritten to the target language's canonical casing convention (lowerCamelCase fields for Dart/Java/Kotlin/TypeScript, SCREAMING_SNAKE enum values for Java/Kotlin, PascalCase enum values for TypeScript, PascalCase type names everywhere). This is not opt-in and there is no config flag to disable it. A GraphQL name that collides with a target-language reserved keyword (e.g. an argument or field named `default`, `return`, `object`) is also automatically sanitized (`default_`, with numeric suffixing on further collisions), while the wire/GraphQL name is preserved. This applies consistently to fields, arguments, enum values, resolver parameters, `@glMapsTo` mappings, and Spring controller/service signatures. **Migration:** if your schema's GraphQL names aren't already in canonical casing (e.g. `snake_case` fields, lowercase type names), regenerating renames the corresponding generated fields/classes/methods. Review the diff after upgrading and update any application code that references generated identifiers directly. Because the generated identifier can now differ from the wire name, `toJson`/`fromJson` are mandatory on every serializer (Dart, Java, Kotlin, TypeScript) as of v5.0.0 — code that reads/writes generated objects without going through them can no longer assume the two names match. --- ## Config file format GraphLink accepts **JSON** (`.json`), **YAML** (`.yaml`), and **YML** (`.yml`) config files. The structure and keys are identical across all three formats. ```yaml title="glink.yaml — equivalent to the JSON example above" schemaPaths: - schema/*.graphql mode: client typeMappings: ID: String Float: double outputDir: lib/generated clientConfig: dart: packageName: my_app generateAllFieldsFragments: true autoGenerateQueries: true ``` --- ## CLI flags ```bash glink # auto-discover config (see below) glink -c glink.json # explicit config path glink -w # watch mode — regenerate on schema change glink -w --debounce 1000 # watch mode, wait 1s after the last change glink --version # print version and exit glink --help # print usage ``` | Flag | Description | |---|---| | `-c ` | Path to the config file. Accepts `.json`, `.yaml`, or `.yml`. If omitted, `glink` searches for `glink.json`, `glink.yaml`, or `glink.yml` starting from the current directory and walking up to the filesystem root. | | `-w` | Watch mode. GraphLink monitors the files matched by `schemaPaths` and regenerates after changes settle (see `--debounce`). | | `--debounce ` | Watch mode only. Milliseconds to wait after the last detected schema change before regenerating, so a burst of saves triggers a single run. Default `500`. Must be a non-negative integer. | | `--print-directives` | Prints the declarations of every GraphLink directive for your IDE and exits. See [Directives](directives.md#declarations-for-your-ide). | | `--version` | Prints the GraphLink version and exits. | | `--help` | Prints usage information and exits. |