Commit Graph
166 Commits
Author SHA1 Message Date
Ben KraftandGitHub 4a06e3f28e Fix typo in README (#58)
## Test plan
read it

Author: benjaminjkraft

Reviewers: aberkan, dnerdy, MiguelCastillo

Required Reviewers: 

Approved by: aberkan

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/58
2021-08-24 10:20:59 -07:00
Ben KraftandGitHub 6689d5a009 Use yaml.UnmarshalStrict (#55)
## Summary:
As Mark pointed out in a review where I realized that the *example* had
a bogus config key (which I hadn't noticed earlier because it was just
using the default value), we should probably do a strict-unmarshal;
there's no reason you should have random extra keys in your config and
if you do it's probably a mistake.  (Or maybe you're running a too-old
version of genqlient for your codebase, which you probably also want to
know.)  Now we do.

## Test plan:
- `make check`
- in webapp, `go mod edit -replace github.com/Khan/genqlient=../genqlient`
  then `make genqlient` produces no diffs (except go.mod/go.sum).


Author: benjaminjkraft

Reviewers: dnerdy, aberkan, csilvers, MiguelCastillo

Required Reviewers: 

Approved by: 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/55
2021-08-23 15:52:08 -07:00
Ben KraftandGitHub 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 KraftandGitHub 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
Mark SandstromandGitHub 832c0bf855 Correct string zero value in design doc (#53)
The design doc talks about the zero value for the `string` and `*string` types and then references `0` and `null`. This PR changes these values to `""` and `nil`.
2021-08-19 18:03:35 -07:00
Ben Kraft dfc9f02efc Actually build the generated code in tests
This revealed one bug already (a redux of #43)!  And will hopefully help
more as unmarshalers get more complicated (thanks to
interfaces/fragments).
2021-06-03 15:48:05 -07:00
Ben Kraft 1f442da041 Switch to cupaloy for snapshots
Slightly uglier filenames, but less code and free diffing!  Approved in
ADR-466 for Khan use.  Fixes #23.
2021-06-03 12:08:56 -07:00
Ben Kraft 3c11f07e62 Make test ID type actually exist
This way I can start to test that the code compiles.
2021-06-03 11:36:45 -07:00
Ben Kraft c2e7dc4e5b Handle omitempty correctly for slices
We were generating broken code; fixes #43.  Also fixes a bug where
applying omitempty to the entire query was broken by e597cac74c.
2021-06-01 15:49:42 -07:00
Ben KraftandGitHub 589680f323 Notes from meeting about content-library
In general it seems like they are happy with the potential future fragments plan!
2021-05-11 14:32:11 -07:00
Ben Kraft caa72dae6a Remove line numbers from export-operations file, again
I messed it up in 6adfe3b2377!  This shows it's really time to turn on
more linters, which would have caught this.
2021-05-03 11:16:13 -07:00
Ben KraftandGitHub 870284271a Some more ideas on how to allow fragments for code-sharing
And clarified some existing ideas and tradeoffs.  This is enough to
make me think we may not need to implement both options, at
least to start.
2021-04-30 16:55:11 -07:00
Ben Kraft c34c5ff505 Turn on test coverage in Makefile/actions 2021-04-23 18:18:07 -07:00
Ben Kraft 6adfe3b237 Remove line numbers from export-operations file
This was sort of accidental from putting them in line numbers, and it
turns out it's more annoying than useful.  Easy enough to remove.

Fixes #40.
2021-04-23 18:14:09 -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 f1914cd9ef log response body, not request body, on non-200 2021-04-22 10:14:26 -07:00
Ben Kraft b399e0d740 move TODOs into issues 2021-04-21 19:05:38 -07:00
Ben Kraft 748f2cf072 Add documentation to types and fields
Fixes #3.
2021-04-21 18:07:36 -07:00
Ben Kraft 32fea7fae4 fix incorrect enum-value type names for enums used as inputs
luckily webapp is now a much more complete test suite and genqlient's
own tests, so it caught this!
2021-04-21 17:41:33 -07:00
Ben Kraft 9bc97108ea fix ExportOperations relative to config file if it's omitted 2021-04-21 11:42:19 -07:00
Ben Kraft 76d372919c make ExportOperations relative to config file 2021-04-21 11:34:25 -07:00
Ben Kraft 2272ad8a12 allow map[string]interface{}, and other such things, as scalars 2021-04-21 11:32:49 -07:00
Ben KraftandGitHub f97d33e6ae more design notes on interfaces/fragments 2021-04-21 10:23:03 -07:00
Ben Kraft 288657fcb9 TODOs 2021-04-16 11:55:35 -07:00
Ben Kraft 93df752ac3 a few more tiny steps in types.go 2021-04-15 19:11:12 -07:00
Ben Kraft be225ba9d0 actually starting to make progress on types.go 2021-04-15 19:00:41 -07:00
Ben Kraft 234c683e21 add a test with a pile of nested interfaces 2021-04-15 18:46:24 -07:00
Ben Kraft 89fe78e11a bit more nibbling at types.go 2021-04-15 18:00:31 -07:00
Ben Kraft 40fc7fdbc5 handle nested lists correctly 2021-04-15 17:49:09 -07:00
Ben Kraft e82a32f47a few more attempts at cleaning up types.go 2021-04-15 17:46:13 -07:00
Ben Kraft f72cb9d346 try to clean up types.go a bit, mostly fail 2021-04-15 17:36:04 -07:00
Ben Kraft 2c087c7821 big overhaul of error-formatting, to get positions more consistently
fixes #2
2021-04-15 17:01:46 -07:00
Ben Kraft ade01c9280 test for uppercasing aliases 2021-04-15 15:50:22 -07:00
Ben Kraft 1bd7f7cb16 put example-test verbose flag in right place 2021-04-15 15:43:46 -07:00
Ben Kraft f8f81dad7b snapshots for errors 2021-04-15 15:42:05 -07:00
Ben Kraft ddf4b03350 allow interface{} as a scalar 2021-04-15 11:50:52 -07:00
Ben Kraft a5fe0943bd only print diff in example_test if test.v is set 2021-04-15 11:38:39 -07:00
Ben Kraft 136ac7729f include alias even if we don't need it 2021-04-15 11:36:46 -07:00
Ben Kraft e597cac74c add option to force using a pointer 2021-04-12 16:01:21 -07:00
Ben Kraft 74411faf52 TODO: auto-caching 2021-04-09 12:18:09 -07:00
Ben Kraft 16523c1f81 add omitempty 2021-04-09 11:51:30 -07:00
Ben Kraft 25a2b45ccc redo comment parsing to set up for field-level config 2021-04-09 09:53:53 -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 e68787ad35 add TODO 2021-04-08 11:28:10 -07:00
Ben Kraft b8f922a41b err explicitly if there's no operation name 2021-04-07 17:18:03 -07:00
Ben KraftandGitHub eae8553c04 couple more TODOs 2021-04-06 15:49:52 -07:00
Ben KraftandGitHub a33595b4b3 update & reorganize TODOs 2021-04-06 15:44:03 -07:00
Ben KraftandGitHub 33f4d9642e issue templates 2021-04-06 14:06:38 -07:00
Ben Kraft e7d9c7d140 update repo to match official open source guidelines 2021-04-06 12:29:28 -07:00
Ben Kraft 574f704ce9 just use the filename, no line number, in source-location 2021-04-06 12:19:12 -07:00