Commit Graph

42 Commits

Author SHA1 Message Date
Ben Kraft 3746ecd063 Add integration tests against a gqlgen server (#50)
## Summary:
We have lots of tests covering codegen, but not a lot that actually run
the code.  For things where all we do is generate types, that's (mostly)
fine (especially now that we actually build the code), but as we
generate more nontrivial non-type code we need to actually run it.

So I wrote some integration tests that spin up a little gqlgen
server, and make calls to it; we can add more over time especially as
the JSON marshalling logic gets complex (to support fragments).
They're more work to write than the snapshot tests, but of course they
can test a lot more.

In addition to gqlgen, I pulled in testify assert/require, because I
really wanted to be able to use assert.Equal and such for these.  I
didn't bother converting existing tests, although I assume they will
become useful elsewhere in time.  Both gqlgen and testify are of course
only used in tests.

Fixes #21 and #24.
Issue: https://github.com/Khan/genqlient/issues/21
Issue: https://github.com/Khan/genqlient/issues/24

## Test plan:
make check

Author: benjaminjkraft

Reviewers: aberkan, dnerdy, benjaminjkraft, csilvers, MiguelCastillo

Required Reviewers: 

Approved by: aberkan, dnerdy

Checks:  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.13),  Lint,  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.13),  Lint

Pull request URL: https://github.com/Khan/genqlient/pull/50
2021-08-20 10:54:41 -07:00
Ben Kraft 700392315a Enable golangci-lint (#49)
## Summary:
It would be nice to have some linting beyond `go vet`!  Now we do.  I
started by copying the config from Khan/webapp.  I did remove a couple
of staticcheck checks that I didn't feel were useful.  (Note also that
exportloopref is the replacement for scopelint in newer golangci-lint.)

Included are all the needed lint fixes; most are stylistic but the
changes in the example are a (minor) bugfix.

Fixes #22.
Issue: https://github.com/Khan/genqlient/issues/22

## Test plan:
make check

Author: benjaminjkraft

Reviewers: aberkan, dnerdy, benjaminjkraft, csilvers, MiguelCastillo

Required Reviewers: 

Approved by: aberkan, dnerdy

Checks:  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.13),  Lint,  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.13),  Lint

Pull request URL: https://github.com/Khan/genqlient/pull/49
2021-08-20 10:39:12 -07:00
Ben Kraft d449acdda3 Clarify object type documentation
Craig pointed out this is a bit confusing when you don't have all the
fields.  Now we say so, but still include the type's description in case
it's useful.

Fixes #37.
2021-04-23 18:13:32 -07:00
Ben Kraft 748f2cf072 Add documentation to types and fields
Fixes #3.
2021-04-21 18:07:36 -07:00
Ben Kraft 136ac7729f include alias even if we don't need it 2021-04-15 11:36:46 -07:00
Ben Kraft b4e8316c6a add support for custom scalars -- mainly adding proper import machinery 2021-04-08 13:07:31 -07:00
Ben Kraft 9c8cf02181 proper test wiring for example test in github actions 2021-04-02 18:04:05 -07:00
Ben Kraft 21954ac62d general pass of README cleanup 2021-04-02 17:01:49 -07:00
Ben Kraft 9fe8f09e8c more miscellaneous fixes while integrating into webapp 2021-04-01 15:04:36 -07:00
Ben Kraft ec6681e715 allow multiple queries-files 2021-04-01 12:29:24 -07:00
Ben Kraft cbebeaaed4 rename in code 2021-03-30 12:41:37 -07:00
Ben Kraft 2c52314494 set opname 2021-03-30 11:27:43 -07:00
Ben Kraft 937540d244 make client an interface 2021-03-25 14:08:12 -07:00
Ben Kraft dd85597577 more wiring for configurable context/client, theoretically should be good enough for khan use 2021-03-22 19:17:06 -07:00
Ben Kraft a42c9b8166 clean up various TODOs and comments 2021-03-22 18:11:51 -07:00
Ben Kraft 463e3ed319 remove pointers for optionality -- shockingly easy 2021-03-22 17:39:22 -07:00
Ben Kraft fed38e4f55 redo type naming 2021-03-19 18:40:58 -07:00
Ben Kraft cf7136ca65 total rewrite to interface handling; not complete but it compiles 2020-07-16 13:28:43 -07:00
Ben Kraft 5042a9a549 allow omitting context 2020-05-01 18:45:39 -07:00
Ben Kraft 7ab06dfd30 add support for enums 2020-04-10 18:16:32 -07:00
Ben Kraft b600df7877 big refactor to put the codegen onto methods of an object 2020-04-10 15:21:23 -07:00
Ben Kraft dfea9bf128 push type-name into types.go 2020-04-10 14:30:56 -07:00
Ben Kraft af5d1bd542 lowercase for arguments 2020-03-27 18:01:56 -07:00
Ben Kraft 01b903b053 Doc comments 2020-03-27 17:44:30 -07:00
Ben Kraft 6caa3fc6c4 Give up on running example in GitHub Actions for now 2020-03-27 16:27:08 -07:00
Ben Kraft 8df2900607 Try example without viewer 2020-03-27 16:18:23 -07:00
Ben Kraft 0911fda620 Fix example envvar name 2020-03-27 16:06:23 -07:00
Ben Kraft 9074926cea Set up a test 2020-03-27 15:57:22 -07:00
Ben Kraft 0dcd124c8e fix filenames, set up go generate 2020-02-06 18:52:00 -08:00
Ben Kraft 35699a73ef more README stuff, example README, other misc cleanup 2020-01-16 17:56:13 -08:00
Ben Kraft 12605986d0 do our own aliasing if the queries aren't right 2020-01-02 19:01:26 -08:00
Ben Kraft 7dfd03738c genql: bits of whitespace 2020-01-02 18:00:23 -08:00
Ben Kraft 9746c818fd genql: quick hack at variables 2020-01-02 17:52:55 -08:00
Ben Kraft 77670363d3 genql: minor cleanups 2020-01-02 16:40:47 -08:00
Ben Kraft 7f6ab70ee3 wire auth to example, fix wire format, it's aliiiiiive! 2019-12-25 21:33:12 -05:00
Ben Kraft 4d880a701e move a bunch of the logic from generated into client 2019-12-25 16:26:32 -05:00
Ben Kraft 9d4b5559f4 wire up example by way of testing 2019-12-24 16:05:10 -05:00
Ben Kraft 9a157470b3 replace handwritten generated code with actual generated code 2019-12-24 15:56:01 -05:00
Ben Kraft e8b5ccbcda generates something mostly plausiblegit add . 2019-12-23 23:22:19 -05:00
Ben Kraft 7a20e2ae74 fill out the easy parts of the codegen 2019-12-23 21:07:07 -05:00
Ben Kraft efa9ccd122 add basic query struct, support 1.12 2019-12-23 19:35:38 -05:00
Ben Kraft a23b0e3756 sketches of generated graphql client 2019-12-21 00:03:19 -05:00