-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity resolver tests #1697
Entity resolver tests #1697
Conversation
} | ||
switch typeName { | ||
case "Hello": | ||
entity, err := func() (*generated.Hello, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generated.Hello
is one bug where we include generated
.
|
||
case "World": | ||
entity, err := func() (*generated.World, error) { | ||
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]interface{})["name"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another bug if the entity query is for the key bar
then this will throw an error.
@vektah these are the tests. I think I may be able to fix the couple of issues I mentioned here some time later today or tomorrow, so sadly these tests are going to be failing until then. |
Reorganizing the tests in the federation plugin a little bit so make it simpler to add more safely without testdata colliding. This is in anticipation for a follow up PR for adding entity resolver tests. Run the tests with `go test ./plugin/federation/...` and verify they all pass. Also verify that the testdata/allthething directory has a `generated` directory specific to that test. NOTE: There is a catch all type of test that I moved to the directory `allthething`. Open to suggestions for a better name! One potential thing to considere here is to split up the tests that use that testdata and break them down into more specific tests. E.g. Add a multikey test in the testdata/entity. For now, Im leaving that as a TODO.
2654671
to
94656da
Compare
The tests work by sending `_entities` queries with `representation` variables directly to the mocked server, which will allow us to test generated federation code end to end. For context, the format of the entity query is something like: ``` query($representations:[_Any!]!){_entities(representations:$representations){ ...on Hello{secondary} }} ``` And `representations` are the list of federated keys for the entities being resovled, and they look like ``` representations: [{ "__typename": "Hello", "name": "federated key value 1", }, { "__typename": "Hello", "name": "federated key value 2", }] ``` The entity resolver tests are in `plugin/federation/federation_entityresolver_test.go` and they rely on `plugin/federation/testdata/entityresolver`. To run the tests: 1. Build the entityresolver testdata - From plugin/federation, run `go run github.com/99designs/gqlgen --config testdata/entityresolver/gqlgen.yml` 2. Run the tests with `go test ./...` or similar
94656da
to
bc3ac51
Compare
Something weird about how the coverage decreased with this PR. |
The tests work by sending
_entities
queries withrepresentation
variables directly to the mocked server, which will allow us to test generated federation code end to end. For context, the format of the entity query is something like:And
representations
are the list of federated keys for the entities being resovled, and they look likeThe entity resolver tests are in
plugin/federation/federation_entityresolver_test.go
and they rely onplugin/federation/testdata/entityresolver
.To run the tests:
go run github.com/99designs/gqlgen --config testdata/entityresolver/gqlgen.yml
go test ./...
or similarI have: