Go: Add support for the gqlgen library#13602
Conversation
owen-mc
left a comment
There was a problem hiding this comment.
Thanks for this contribution. There's very little to change. Tests are failing because the stub in graph/generated.go uses two spaces rather than a tab (like the rest of the file does). I've indicated how to switch to an inline expectations test in comments. They are much easier to read and edit in future.
go/ql/lib/change-notes/2023-06-28--add-support-for-gqlgen-framework.md
Outdated
Show resolved
Hide resolved
go/ql/test/library-tests/semmle/go/frameworks/gqlgen/gqlgen.expected
Outdated
Show resolved
Hide resolved
go/ql/test/library-tests/semmle/go/frameworks/gqlgen/graph/schema.resolvers.go
Outdated
Show resolved
Hide resolved
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
…r/codeql into ruby/add_gqlgen_support
…ema.resolvers.go Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
| ) | ||
|
|
||
| // CreateTodo is the resolver for the createTodo field. | ||
| func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { // $ resolverParameter="definition of input" |
There was a problem hiding this comment.
@owen-mc Thanks! is there any documentation about the syntax of these tests? what is the $ for? can you add any string instead of definition of input?
There was a problem hiding this comment.
Ok, seems like every line where Gqlgen::ResolverParameter matches will be tagged with the resolverParameter tag with its toString value assigned to the tag value, so in the inline test we can check for tags with specific values. I guess the $ is just to flag that line as an inline test and not just an ordinary comment? still not sure where the "definition of input" value comes from? is that the toString() of a DataFlow::ParameterNode?
There was a problem hiding this comment.
The documentation is at the top of InlineExpectationsTest.qll. "definition of input" is defined by value in hasActualResult in go/ql/test/library-tests/semmle/go/frameworks/gqlgen/gqlgen.ql. definition of X is the toString() of a ParameterNode for a parameter named X.
There was a problem hiding this comment.
Thanks! Will use these tests the next time
There was a problem hiding this comment.
I should also mention InlineFlowTest, which is very easy to use.
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
…r/codeql into ruby/add_gqlgen_support
|
Tests are failing because of formatting again (mostly tabs vs spaces). That's stopping us from running the actual tests. The easiest way to fix it is to go to All the code changes look good. I will merge when tests pass. |
Adds support for the GQLgen library