Skip to content

Online generator: description attributes and scalar mapping review - #130

Merged
joadan merged 4 commits into
mainfrom
docs/online-generator-description-attributes
Oct 27, 2026
Merged

joadan merged 4 commits into
mainfrom
docs/online-generator-description-attributes

Conversation

@joadan

@joadan joadan commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Adds the remaining generator settings to the online generator on the docs site, and lets the user review how the schema's scalars map to C# types before generating.

Online generator

  • Description attributes switch (on by default, like the CLI).
  • Scalar mappings: each tab has a Load schema button. After loading, the page shows a summary (scalars, how many generate a CustomScalar class, how many are changed) and a Review scalar mappings modal listing every scalar - the schema's own first, then GraphQL's built-ins - with an editable C# type, a reset per row, Reset all, and Copy as linq2graphql.json (the page's settings as a config file; the token is never included).
  • Generate reuses the loaded schema while the source (url/token/schema text/Include Deprecated) is unchanged.

Generator

  • ClientGenerator exposes ReadSchemaAsync, ReadSchema, ReadSchemaFromSdl and Generate(RootSchema), so a schema can be read once and generated from more than once.
  • Schema.GetScalars() lists the scalars with their default mapping (ScalarInfo).
  • Field.CoreType no longer keeps the first run's type when the same schema is generated with different settings.
  • Opting a GraphQL built-in (Int, Float, String, Boolean) out of the mapping ("Int": null) now fails with a clear error; before, it produced a client referring to a class that was never generated. Mapping a built-in to another type still works.

Tests / docs

  • New ScalarMappingTests for GetScalars, generating twice, and built-in remap/opt-out.
  • README and the Generator docs page note that built-ins can be remapped but not opted out.

On by default, like the config file setting. Off leaves schema descriptions
as XML doc comments only, without [Description] attributes.
Rows of scalar name and target type, the same targets the config file's
scalarMappings accepts plus "CustomScalar class" for null. Validated with
Helpers.ResolveScalarMappings, so errors match the command line; a scalar
mapped twice is an error. Both generate paths share CreateGenerator().
Instead of typing scalar names blind, the page reads the schema first and
lists its scalars with their default C# types. A summary shows how many
generate a CustomScalar class and how many were changed; a review modal
edits them and copies the page's settings as a linq2graphql.json file.

Generator:
- ClientGenerator.ReadSchemaAsync/ReadSchema/ReadSchemaFromSdl read a schema
  without generating, and Generate(RootSchema) is public.
- Schema.GetScalars() lists the scalars with their default mapping
  (ScalarInfo).
- Field.CoreType no longer keeps the first run's result: it depends on the
  run's settings, so generating twice from one schema with different scalar
  mappings returned the first run's types.
- The online generator's review modal lists every scalar of the schema,
  GraphQL's own Int/Float/String/Boolean included (after the schema's own
  scalars), each with an editable C# type. Built-ins offer no CustomScalar
  option.
- Generator: mapping a built-in scalar to null now fails with a clear
  message. No CustomScalar class is generated for them, so "Int": null used
  to produce a client referring to a type that does not exist. Mapping them
  to another type (Int -> long) still works. Helpers.BuiltInScalars replaces
  Schema's private list.
- README and Generator docs say built-ins can be remapped but not opted out.
@joadan
joadan merged commit 435107c into main Oct 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant