Repository navigation
import: keep Dang's names out of schema imports - #275
Merged
Merged
Conversation
Deploying dang with
|
| Latest commit: |
55312dc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8d8efd13.dang-3kk.pages.dev |
| Branch Preview URL: | https://schema-values-over-builtins.dang-3kk.pages.dev |
An unresolved qualified type now says where it was looked up: `type "Container" not found in Dagger` rather than `unresolved type: Container`, which read as if the name had been looked up unqualified. Signed-off-by: Alex Suraci <[email protected]>
A schema import's namespace held Dang's builtins and prelude next to the schema's own names: its type scope fell back to the prelude, and its value scope had the builtins bound into it, after the schema's values. So `Test.Path` and `Test.Random` resolved, and `Test.toString`, where the schema has a toString field, type-checked as the field but ran the builtin. Now the namespace holds only what the schema defines: its types (with GraphQL's built-in scalars, which every schema has), Query fields and directives. The type scope falls back to just ID/String/Int/Float/Boolean, and ValueScopeFromSchema binds no builtins. Builtins are reached unqualified, where imports still never shadow them. Nothing read builtins through the import's value scope: unqualified names resolve in the importing scope. The test server gains a `toString(value: Int!): String!` field to cover it. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
schema-values-over-builtins
branch
from
November 9, 2026 14:14
91bab76 to
55312dc
Compare
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.
A schema import's namespace (
Test.…) now holds only what the schema itself defines. Dang's own builtins and prelude are no longer re-exported through it.Problem
The namespace used to hold Dang's builtins and prelude alongside the schema's names:
TypeScopeFromSchemafell back to the prelude, soTest.Path,Test.Random,Test.Regexpand the codec namespaces resolved through the import.ValueScopeFromSchemabound the builtins into the import's value scope after the schema's values. A builtin therefore overwrote a schema binding with the same name. With a Query field namedtoString,Test.toString(value: 7)type-checked as the schema's field but ran Dang'stoStringand returned"7".Change
The import's namespace now holds only:
ID,String,Int,Float,Boolean), which every schema has. The schema's type scope falls back to just those five scalars instead of the prelude.ValueScopeFromSchemabinds no builtins. SoTest.toStringis the schema's field when the schema has one and an error otherwise, andTest.Pathis an error.The errors read:
field "print" not found in Testfield "Path" not found in Testtype "Regexp" not found in Test, for type annotationsA small separate commit makes every unresolved qualified type name its namespace:
type "X" not found in Nsinstead ofunresolved type: X.Unchanged:
toStringis Dang's.Test.String) still work.encode/decodegrafted on:Dagger.JSON.encodeworks.Out of scope: native Dang module imports (
[imports.Lib] path = …) still expose the prelude and builtins (Lib.toString,Lib.Path). The same rule applies to them, but fixing it needs a different mechanism.What relied on the old behavior
I found nothing that reads builtins or prelude names through an import's namespace.
NewEvalEnvWithSchema, before 98c8135).core/sdk/dang, which only passesImportConfigs), the REPL and the docs tools (BuildScopesFromImports), the LSP, and directory mode (evaluateDirectoryFiles). In each, unqualified builtins come from the importing scope (NewValueScope/NewPreludeTypeScope), never from the import..dangfiles, found no qualified use of a prelude or builtin name through a schema import. The onlyLib.toString/Lib.loopuses are native-module imports of the module's ownpubfunctions.TestRunDirDeclarationShadowsImportAlias, which now expects the new qualified message.Tests
tests/gqlserver) gainstoString(value: Int!): String!, which returns"schema toString: <n>".generated.gois regenerated.tests/test_import_namespace.dang:Test.toString(value: 7)reaches the server's field. This failed on main withleft: "7".toString(7)is still the builtin.Test.String/Int/Float/Booleanresolve.import_qualified_prelude_typecoversTest.Path("a/b").import_qualified_builtincoversTest.print("hello"), a builtin the schema lacks.import_qualified_prelude_type_annotationcoverslet pattern: Test.Regexp! = ….Maintainer decisions
pubdeclarations), built with a different mechanism.