Code Monkey home page Code Monkey logo

Comments (9)

lucianjon avatar lucianjon commented on May 19, 2024

@gmac I had to track this one down myself but it's happening in formatSelectionSet here https://github.com/movio/bramble/blob/main/query_execution.go#L100 and that will trace down to expandAndFormatVariable. Essentially all of the variables are stored inside the http context and then inlined last minute based on matching up the variable names.

from bramble.

nmaquet avatar nmaquet commented on May 19, 2024

@gmac variables are also used to evaluate @skip and @include directives here:

op = s.evaluateSkipAndInclude(variables, op)

(you can see how they're extracted from the context, too).

from bramble.

gmac avatar gmac commented on May 19, 2024

Whhhoooaa, I totally overlooked the significance of the formatting lib here. I kind of assumed that was just a “dumb” string utility and that all the primary logic would be happening as an AST transformation in the execution process. Thanks for the pointer, I see it now!

One related question on @skip and @include… I was surprised to see those included in the gateway. Technically, couldn’t those just get passed through to the underlying subservices to evaluate? I guess that could mess with null evaluation?

from bramble.

nmaquet avatar nmaquet commented on May 19, 2024

One related question on @Skip and @include… I was surprised to see those included in the gateway. Technically, couldn’t those just get passed through to the underlying subservices to evaluate? I guess that could mess with null evaluation?

It was relatively easy to implement so we added it in. I don't think there is a downside to doing this? With very large documents, it may also be quite a bit more efficient, since pruning the selection set may result in calling fewer downstream services.

from bramble.

gmac avatar gmac commented on May 19, 2024

Makes sense. I can’t think of a downside either, I was just surprised to see them there.

from bramble.

benzolium avatar benzolium commented on May 19, 2024

A year later I've probably found a downside of inlining. 🙂

I'm trying to implement patch-like update mutation and distinguish between null fields and not send (undefined).
So on service side I'm looking into variables (selection set) and skip any of them if they are not present.

Is it possible to pass variables to downstream services? Or maybe there is another workaround?

from bramble.

pkqk avatar pkqk commented on May 19, 2024

@benzolium we also found an issue with inlining variables recently with custom scalars and the difference between serialisation as JSON and GraphQL.

I think the answer will be to stop expanding and inline variables into the downstream service queries, and instead extract the relevant variables from the request payload, and pass them downstream.

from bramble.

benzolium avatar benzolium commented on May 19, 2024

@pkqk could you please guide me how can I do it? Should I make a fork of bramble?

from bramble.

pkqk avatar pkqk commented on May 19, 2024

@benzolium if you'd like to have a go at it then you can fork bramble and make a PR to this repo.

In format.go it currently extracts the variables from the request context while formatting the queries for all the downstream services, and then inlines them into each query.

You'd need to alter buildBoundaryQueryDocuments and executeBoundaryQuery called in execution.go so instead it collects the variables used in each query and passes them along to the downstream services.

from bramble.

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.