Comments (6)
This is how I test the resolver for a model called 'User' in one of the apps I built:
gql_query =
<<~GQL
query entities {
_entities(representations: [ {__typename: User, id: "123"} ]) {
...on User {
id
first_name
last_name
}
}
}
GQL
User.create(id: 123, first_name: 'David', last_name: 'HH')
result = DiscussionSchema.execute(gql_query, context: context)
expected_result = [{ 'id' => '123', 'first_name' => 'David', 'last_name' => 'HH' }]
expect(result.dig('data', '_entities')).to eq(expected_result)
I extracted this answer from a more complex test suite I wrote several months ago, so it may contain some errors. Hopefully it provides enough guidance to be helpful.
The gem's test suite also has some examples you can see here: https://github.com/Gusto/apollo-federation-ruby/blob/master/spec/apollo-federation/entities_field_spec.rb#L164
from apollo-federation-ruby.
Managed to test my changes. If it'd be helpful to others, I might be able to contribute some documentation in regard to what an rspec test could look like for apollo federation integration.
from apollo-federation-ruby.
Hi @kented , your approach was how I tested one of our internal app that's using federation. It works well but can be pretty confusing to someone who has less exposure to federation. But I do like that it creates a relatively honest test.
Maybe in the future, the maintainers might consider some test helpers. For now, I'll try to add a PR that highlights this as a testing strategy, save future readers some time hopefully.
from apollo-federation-ruby.
@kented I don't think the project has documentation in regards to that, probably the best approach you can take is integrating your API with the Apollo Gateway and test your queries and mutations. You can also query the _service
and _entities
fields directly. You can take a look at the tests on how to do that.
from apollo-federation-ruby.
@kented Would you mind sharing your approach?
from apollo-federation-ruby.
Nice. I think what you've added to the README will be helpful to folks who are wondering how to test their implementation.
from apollo-federation-ruby.
Related Issues (20)
- Enabling federated tracing breaks multiplex HOT 5
- unable to configure federation directive namespace HOT 7
- Find a home for MinimumWageMailer and its templates HOT 1
- Using a dataloader inside `resolve_reference` does not work HOT 10
- passing `@federation__shareable` to type PageInfo HOT 17
- The automated release is failing 🚨
- Add `resolvable` argument to `key` directive HOT 2
- v3.4.x updates federation directive version to 2.3, fails schema checks with Apollo Studio HOT 17
- The automated release is failing 🚨
- support @composeDirective
- Representation fields in entity queries are not validated at query execution time HOT 5
- support @cacheControl HOT 1
- Namespace all federation directives HOT 2
- Federation SDL is invalid for non-Apollo tools HOT 3
- Fowarding headers from Supergraph to subgraphs HOT 2
- Examples - Share
- Development / maintenance status of this gem HOT 7
- Federation directives are not showing up in SDL output HOT 1
- Gateway will merge incorrect data if subgraph changes entity order
- Bug: Orphan types are ignored since version 3.8.5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-federation-ruby.