Repository navigation
Online generator: description attributes and scalar mapping review - #130
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Generator
ClientGeneratorexposesReadSchemaAsync,ReadSchema,ReadSchemaFromSdlandGenerate(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.CoreTypeno longer keeps the first run's type when the same schema is generated with different settings.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
ScalarMappingTestsforGetScalars, generating twice, and built-in remap/opt-out.