Skip to content

Conversation

@gvaughn
Copy link
Contributor

@gvaughn gvaughn commented Nov 19, 2025

I got bit the other day by a syntax error in a GraphQL document in a module attribute of a test.
The error message I received sent me off in the wrong direction. I thought it'd be nice if there
was some way to lint those. Co-workers also thought it a nice idea plus formatting since Absinthe
only formats standalone .gql or .graphql files.

So here's a sigil that formats or prints validation errors to system error. Here's an example
output from one of the added tests:

~GQL sigil validation error at [file: ~c"test/absinthe/sigil_test.exs", line: 24]
Parsing failed at `-won't-lex` ([%{line: 1, column: 18}])

Note: I limited the printing of validation errors only to the sigil. I wanted to put it in
Absinthe.Formatter however, I wanted to ensure there wasn't some backward compatibility
to be concerned with.

@gvaughn gvaughn changed the title add GQL sigil to format and lint static GraphQL docs feat: add GQL sigil to format and lint static GraphQL docs Nov 19, 2025
@cschiewek
Copy link
Member

@gvaughn looks like dialyzer is failing

@gvaughn
Copy link
Contributor Author

gvaughn commented Nov 19, 2025

Yes. I'm trying to detangle that. I already pushed one commit thinking it was referencing the "safety" other clause I used, so I removed it. However, I based my case conditions on Sdl.parse which includes an other.

Digging deeper, Phase.parse has a comment about dialyzer not quite getting this right.

@gvaughn
Copy link
Contributor Author

gvaughn commented Nov 20, 2025

@cschiewek can you allow the CI jobs to run once more? Dialyzer passed for me locally.

@cschiewek cschiewek merged commit 3aef283 into absinthe-graphql:main Nov 21, 2025
19 checks passed
@rockneurotiko
Copy link

I just saw this on the release notes, and literally a couple of months ago I did a library to format and validate queries/mutations against schemas (including schemas from Absinthe), we've been using it on production for a couple months now to build queries against external APIs and for testing those APIs and our internal API too.

The library: https://hexdocs.pm/graphql_query/GraphqlQuery.html

This message is not to spam the library, but to question if the sigil added in this PR makes sense inside Absinthe, or if it makes sense as an external library.

@gvaughn
Copy link
Contributor Author

gvaughn commented Dec 1, 2025

@rockneurotiko I wasn't aware of your library. That's quite comprehensive! My goal was to just expose the parsing errors Absinthe already generates. I think there's room for something basic baked into Absinthe, plus your GraphqlQuery library. I guess the most important thing is to ensure the basic sigil can be overridden/replaced.

I'll defer to @cschiewek 's opinion on this.

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.

3 participants