Comments (2)
Interesting idea. How would this work? The schema might tell you enough for basic types, some of the time, eg 'string' = 'asdf', but what about custom scalars? use the zero value? but I feel like getting tests to pass any user implemented validation (eg user id must be a valid id) would be really tricky. It probably ends up looking like the apollo mocking api but backwards.
I usually write tests to cover the graph manually, executing mutations and asserting that they are present in the query. There is a client
package in this repo to make that a little easier. Take a look at the tests in any of the examples eg
from gqlgen.
I think that the tests for the generated code should only test that the code generated is valid and does what is expected. In this scenario we could mock the Resolvers interface generated as this is the root node to the query (the query and mutation fields) and we can control from the top level the objects which are returned and resolved further down the tree, assuming that we can initialise user generated mocks, using the structures themselves or a package like mock
I think that these tests should not have to worry about user implemented validation, as stated above we can control the objects returned from root nodes, and any resolver funcs lower down the tree.
As you stated, the difficulty is in Custom scalar types.
from gqlgen.
Related Issues (20)
- testifylint v1.3.0 lint notices require called in goroutines in testsuite HOT 1
- Errrrors HOT 2
- possible denial of service attack due to unlimited errors CVE-2023-49559 HOT 6
- Federation error `federation and exec must be in the same package`
- bug: Generating Required Custom Type as Pointer HOT 2
- Support an inline resolver function to access function closure HOT 1
- Support an inline resolver function to access function closure HOT 1
- Upgrade to gqlparser v2.5.15 - CVE-2023-49559 fix HOT 2
- Error on Mutation resolver cannot be parsed by Apollo Client HOT 1
- The @goExtraField directive violates the graphql spec HOT 3
- follow-schema support for model files
- client.SSE() block forever HOT 1
- Generated code unexpected for word containing ID (e.g. Idea) HOT 2
- Using @entityResolver(multi: true) causes "directive entityResolver is not implemented" to be thrown when the entity is used in another Query HOT 1
- Use embedded templates in root file generation HOT 1
- Command doesn't work after upgrade HOT 1
- Initialisms with digits in the middle of them aren't recognized HOT 1
- Website: wrong link to the latest version
- Bazel builds no longer work after landing #2988 HOT 1
- Is posible to reuse field resolver? Also is posible to set global resolver and use by name?
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 gqlgen.