-
Notifications
You must be signed in to change notification settings - Fork 28
Gracefully support Query.node in @exposeField; clearer behavior when missing #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…n when Query.node is absent; add dev shell for local builds
…e when Node is implemented (refetch generation handled gracefully)
(generated with gpt5 pro) |
per patryk:
here we need to add another condition, object_implements_node && Query.node is "valid" don't know if we can do it at this step |
|
||
unprocessed_items.push(SelectionType::Scalar(unprocessed_scalar_item)); | ||
match unvalidated_isograph_schema | ||
.create_new_exposed_field(expose_as_field, parent_object_entity_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's have create_new_exposed_field
return a Result<Option<...>>
and leave this code unchanged
if field == "node" { | ||
let Some((query_name, _)) = self.find_query() else { | ||
return Err(WithLocation::new( | ||
CreateAdditionalFieldsError::PrimaryDirectiveFieldNotFound { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here, let's return None
.expect("canonicalize cwd") | ||
.to_string_lossy() | ||
.to_string(); | ||
db.set(CurrentWorkingDirectory(cwd_str.intern().into())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to use the tmp
folder, we can a bunch of calls to db.set(...)
instead. Happy to figure out how to make that work unless you're interested in it. But not a blocker, the test lgtm
Summary
field: "node.asType"
but the schema lacksQuery.node
.node
as rooted at the Query type and checks for existence.Query.node
is absent, skips generating the refetch field instead of erroring (and returns a more specific error variant internally).Motivation
Node
triggers a refetch field via@exposeField
(field: "node.as<Obj>"
). In schemas withoutQuery.node
, compilation fails with "Invalid fieldnode
in @exposeField directive".Node
but intentionally do not exposeQuery.node
.Changes
Query.node
is absent (clearer than a generic InvalidField).Query.node
is missing; continue compiling the rest of the schema.Notes
Query.node
, while making compilation resilient for projects that don’t.Query.node
whenever any type implementsNode
; this PR aims to be permissive and avoid breakages while improving the error.Testing
Query.node
, the compiler proceeds without failing.Related gist/repro: https://gist.github.com/randallb/df13780a215c74f3f9e05d81f4fe6e03