Skip to content

Conversation

@ivymarkwell
Copy link
Contributor

While developing, I encountered an issue where calling Absinthe.Schema.to_sdl/1 crashes if a custom directive is defined with an input_object argument and then used on a field.

From my understanding, input_objects are valid according to the GraphQL spec (https://spec.graphql.org/October2021/#sec-Language.Directives and https://spec.graphql.org/October2021/#sec-Type-System.Directives.Validation).

Directives have a name along with a list of arguments which may accept values of any input type.

and

The argument must accept a type where [IsInputType](https://spec.graphql.org/October2021/#IsInputType())(argumentType) returns true.

This happens during the rendering of the directive's arguments in Absinthe.Schema.Notation.SDL.Render.render_value/1. This function currently doesn't seem to handle input objects as values as far as I can tell. When I inspected the render_value function, the name was getting passed as an atom which was blowing up since this wasn't a proper Inspect.Algebra document structure.

You can reproduce the error I was seeing by reverting the change in lib/absinthe/schema/notation/sdl_render.ex and running the tests. It should fail with the following (prettified) stacktrace:

** (FunctionClauseError) no function clause matching in Inspect.Algebra.concat/2

Stacktrace:
  (elixir 1.18.1) lib/inspect/algebra.ex:614: Inspect.Algebra.concat(:enabled, {:doc_cons, ": ", "true"})
  (absinthe 1.7.10) lib/absinthe/schema/notation/sdl_render.ex:406: Absinthe.Schema.Notation.SDL.Render.render_value/1
  ...
  test/absinthe/schema/sdl_render_test.exs:267: Absinthe.Schema.SdlRenderTest."test Render SDL from blueprint defined with macros"/1

Let me know if I'm misunderstanding something! I'd love to fix this on my side or improve my understanding of what's expected according to the GraphQL spec.

Thanks 🙂

@ivymarkwell ivymarkwell force-pushed the fix-input-object-sdl-render branch from 5be166a to 97353b4 Compare August 6, 2025 03:13
@cschiewek cschiewek changed the title Fix SDL rendering for directives with input objects fix: SDL rendering for directives with input objects Oct 28, 2025
Copy link
Member

@cschiewek cschiewek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. If you can update your branch from main and get tests passing I'll approve and merge.

@ivymarkwell ivymarkwell force-pushed the fix-input-object-sdl-render branch from 97353b4 to c60f16c Compare October 28, 2025 20:03
@ivymarkwell
Copy link
Contributor Author

@cschiewek I believe those tests should be fixed now. I resynced my cloned repo, did a git rebase master on this branch and applied a fix in this commit.
However, I can see now there is a 2 workflows awaiting approval status. I'm not sure how to resolve that so let me know what else I need to do. Thank you.

@ivymarkwell ivymarkwell requested a review from cschiewek October 28, 2025 20:44
@cschiewek cschiewek merged commit 02b955c into absinthe-graphql:main Oct 29, 2025
19 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.

2 participants