Giter Club home page Giter Club logo

Comments (3)

acarl005 avatar acarl005 commented on May 12, 2024 1

GraphQL args are now the third parameter for sqlJoin. Publish in v0.9.4.

from join-monster.

acarl005 avatar acarl005 commented on May 12, 2024

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.

kamek-pf avatar kamek-pf commented on May 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.