Comments (12)
@TGNThump it could be a second method called executeAsResponse or you could just call getContent on the Response object. The point is we can't get the data before it gets manipulated which makes testing a lot harder.
from lighthouse.
Hmm. I'm not sure I like this idea, purely because it makes it hard to use the library in cases where you aren't parsing a response object, such as loading a query from another source (DB) or for subscriptions, where you aren't going to be returning a response object.
from lighthouse.
@olivernybroe I personally like the executeAsResponse
idea. If there's no PR I'll add it this weekend but thanks for the feedback!!
from lighthouse.
@chrissm79 Sounds great! Looked into it, but tbh. I have no idea how to implement it.
from lighthouse.
Are you still interested in doing something like this? I think the tests work fine as they are, and i am not too big a fan of adding methods just for the sake of testing.
from lighthouse.
@spawnia I think it is really needed. Writing tests right now in Lighthouse isn't that nice as I can only check the returning data, not the actual data, which is what I am testing for in that particular test.
I think it is worth adding a method just for the sake of testing.
from lighthouse.
What is it that you are actually trying to test? For an integration test, we should definitely test the public interface. If it is a unit test, maybe we do not even need to execute the query fully?
from lighthouse.
@spawnia Sometimes I have a complex data definition in graphql. So I want to make sure that the data returned is the correct model. I am not interested in what fields I have defined in my SDL. I am interested in what is received before the data is transformed.
from lighthouse.
Seems like that can be achieved by calling the resolve function directly. Should this prove to be insufficient, you can add some utility functions to TestCase.php
to help with such tests.
from lighthouse.
@olivernybroe Have you done anything on this? I would like to avoid adding complexity to the resolution itself, so if you can achieve what you need by adding a helper for testing, i would be up for including it as part of the test suite.
from lighthouse.
@spawnia haven't done anything for this.
from lighthouse.
I think this is a very specific use case for testing, and can be worked around. I think the public API should be kept small, and we can not really control the final execution result without reaching into the GraphQL core library.
Closing this for now, but am open for PR's that improve testability.
from lighthouse.
Related Issues (20)
- Generate schema fail! HOT 1
- Exception Undefined array key "schemaExtensions" HOT 1
- Clear Cache (private) HOT 1
- Segmentation fault when handling large payloads HOT 8
- Requesting local scopes can pass parameters HOT 1
- New directive that mirrors functionality of `whereHas` for relations (not `@whereHasConditions`) HOT 1
- `make setup` failed on macOS
- Access context in `FieldMiddleware` HOT 3
- CanArgs is defined twice in schema-directives.graphql
- `extend scalar X` directives are lost
- @canFind is missing "model" argument in graphql definition HOT 1
- Allow to customize the unique key for `PaginatedModelsLoader`
- artisan lighthouse:union stub appears to be incorrect HOT 1
- Problem with subscription middleware HOT 2
- An error occurs in the SubscriptionRegistry when sending a subscription event via Subscription::broadcast with Laravel Octane (Swoole) HOT 5
- Laravel v11 support dependancy missing
- Enum Support for Morph Types HOT 1
- Mutation transaction seem not work HOT 4
- Failed to find class App\GraphQl\Queries\TodoQuery in namespaces [] for directive @paginate
- @whereNull and @whereNotNull No directive found!
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 lighthouse.