Comments (3)
GraphQL args are now the third parameter for sqlJoin
. Publish in v0.9.4.
from join-monster.
Hello @kamek-pf. I like learning about these use cases. It certainly helps me improve the project.
This stumped me for a while. I would've taken the same approach for your first point. We've found that relying on views rather than the actual tables is the best way to accommodate SQL schemas.
To your second point, what if you made a slight change to the schema...
{
someTable {
someValue # -> GraphQLInt
someString # -> GraphQLString
someStringIntl(language: "en") {
someString # -> GraphQLString
}
}
By making the language a parameter rather than a field, it might work. You could put the language into the where condition. Or better yet, I could add another parameter to the sqlJoin
function which receives the GraphQL args. Then the JOIN
condition could include the language.
{
someTable {
someValue # -> GraphQLInt
someString # -> GraphQLString
en: someStringIntl(language: "en") {
someString # -> GraphQLString
}
fr: someStringIntl(language: "fr") {
someString # -> GraphQLString
}
}
You could call the someStringIntl
field multiple times using GraphQL aliases.
Would this fulfill your use case?
P.S. It looks like GitHub has added flavored markdown support for GraphQL!
from join-monster.
Hi @acarl005,
I spent some time thinking about all this and I came up with similar ideas.
I don't think being implicit about the language (like I wanted to with someString
) is such a good idea anymore. If the client application needs to let the user choose a different language, then a GraphQL client lib like Relay would have no way to tell what fields need to change.
I'll probably go for a new TranslatedString
object type :
TranslatedString(lang: String):
language: String,
text: String
Every string that has to be translated could be an array of TranslatedString
. It could be filtered with the lang
parameter, or return the whole list if the parameter isn't specified.
{
someTable {
someString(lang: "en") { text } # as a regular client
someString { language, text } # as a CMS user
}
}
This would cover all my use cases.
someString(lang: "en") { text }
would always return an array with exactly one element, a bit awkward, but still a decent trade off.
This can already be implemented in the current state of Join Monster (by filtering from within the resolver), but as you said, having the args accessible from sqlJoin
would be even better. I imagine this could be useful in many different situations.
Thanks again for taking the time to look at this @acarl005 :D
from join-monster.
Related Issues (20)
- Update to compat version of relay
- Missing results when using batch HOT 2
- sqlPaginate always adds total aggregation even if it's not even used
- Typescript type errors HOT 1
- Link to demo does not work HOT 5
- 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 1
- joinMonster creating invalid MySQL sql HOT 1
- Unsupport many-to-many relation on graphql v15.8 and join-monster v3.1.1 using postgres? HOT 1
- 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
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.