Comments (7)
The the problem was that the two disjoint fields where coming from the db in different objects.
So the latter overrode the first one, that is why you were alway having just one of those.
Now I check if we have a result that is an object and a new piece comes, we just merge it.
{ author: { capitalizedLastName: "..." } } + { author: { email: "..." } } = { author: { capitalizedLastName: "...", email: "..." } }
in the end I was able to fix both modes with same approach in different places:
join-monster/src/batch-planner/index.js
Line 102 in a5395c5
join-monster/src/resolve-unions.js
Line 13 in a5395c5
from join-monster.
@Grundlefleck I'd love your input in the solution I've proposed #519
And If you can tell me if you have a test for sqlBatch or how did you know it would not work there.
Thanks for such a detailed issue, investigation, pull request and patience.
from join-monster.
I added this test 06f2a26 and it passes in both batch and join modes.
I also tested that on master. with same results.
Note that there is an extra object, I believe disjoint fields need more work.
We could merge my PR that make multiple disjoint fields work in join mode which solves @Grundlefleck
Then work in PRs addressing:
- multiple disjoint in batch mode
- remove extra object in single disjoint in batch mode
- remove extra object in single disjoint in join mode
from join-monster.
fixed by #519
from join-monster.
Hi @nicoabie thanks for looking into it.
@Grundlefleck I'd love your input in the solution I've proposed #519
I confess I don't really understand how it works, but probably it's because I can't visualise the runtime types when moveProp
is called. Is the strategy to merge (via Object.assign
) the field representing the unioned type? So in the example test case, the author
field would be like: { capitalizedLastName: "...", email: "..." }
and that would be passed back?
And If you can tell me if you have a test for sqlBatch or how did you know it would not work there.
Only from running e.g. npm run test
which would execute the same tests using STRATEGY=batch
. I didn't even consider batch mode until I ran the test suite... which is a sign of a great test suite! 😄
Thanks for such a detailed issue, investigation, pull request and patience.
No, thank you.
from join-monster.
we just merge it.
Gotcha. I had in my head that the resultant object needed to match the fields being requested, and that any extra fields not requested in the GQL query input might trip some validation.
Not sure where I got that from, but if it's not a concern then making all fields available is way simpler than trying to wrangle a call to resolveType()
.
from join-monster.
Yes, It will match exactly the fields requested. The thing is that the fields came is different objects. That's all :)
from join-monster.
Related Issues (20)
- tsd failing locally HOT 2
- Fails if I extend GraphQLObjectType HOT 1
- Must call joinMonster in a resolver on a field where the type is decorated with \"sqlTable\" HOT 9
- Cannot read properties of undefined (reading 'sqlTable') HOT 2
- Failing type defs
- Issue with GlobalIDs not transforming back to "native" uuid4 IDs
- bug in joinMonster.getNode(): def.args not iterable HOT 4
- Querying the same relation multiple times as aliases with different args results in wrong data HOT 5
- Remove requirement for uniqueKey to be defined
- Pagination with dynamic sorting does not support null values. HOT 2
- joinMonster creating invalid MySQL sql HOT 2
- Unsupport many-to-many relation on graphql v15.8 and join-monster v3.1.1 using postgres? HOT 2
- Batching JoinMonster calls
- The HTTP server example code is broken due to deprecation of kao-graphql HOT 1
- join-monster fails to work in a react native deployment HOT 1
- Typescript type error for GraphQLFieldExtensions HOT 1
- Test flake on database startup
- Readthedocs build fails when master is updated
- Namespace/prefix generated aliases with `$` or similar HOT 5
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 join-monster.