it is v2:
rest("/v2/swapi-graphql/all-films").get()
.produces("application/json")
.to("direct:swapi-graphql-all-films2");
from("direct:swapi-graphql-all-films2")
.setBody(constant("{ allFilms { films { title director releaseDate } } }"))
.to("graphql://https://swapi-graphql.netlify.app/.netlify/functions/index";)
.convertBodyTo(String.class);
The reason for the failure is interesting:
1. GraphQL component constructs POST and invokes HTTP
2. netlify's index URL returns 301 with /graphql  - and that forces POST to
be changed to GET by underlying http client.

looking at HTTP spec - it should have been 308
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308 -
but haven't seen 308 adopted widely.

ચિરાગ/चिराग/Chirag
------------------------------------------
Sent from My Gmail Account


On Wed, Aug 20, 2025 at 3:18 PM Claus Ibsen <claus.ib...@gmail.com> wrote:

> Hi
>
> Can you tell if its v1 or v2 in that sample code that fails (due to a
> redirect)
>
> On Tue, Aug 19, 2025 at 12:09 AM Chirag <w35ank...@mozmail.com.invalid>
> wrote:
>
> > Picking up a thread from Linkedin Discussion
> >
> >
> >
> https://www.linkedin.com/posts/diego-giudici-2a4a82183_apache-camel-exec-component-to-be-used-to-activity-7361417086029520896-rX9S?utm_source=share&utm_medium=member_desktop&rcm=ACoAAAADB-oBkocmID4JNAjX2CC91jH5a8sV5l4
> >
> > here is route:
> > https://gist.github.com/chiragsanghavi/b83ef5babc6d02b2757ae6a9cd100281
> >
> > Technically this is not a bug, as site
> > https://swapi-graphql.netlify.app/.netlify/functions/index leads to a
> > direct, which shouldn't happen in real life.
> >
> > GraphGL component initiates request using a POST, but redirect is handled
> > by Apache Common HTTP Client - and as GET - which is where the "query" is
> > not passed to the redirected URL.
> >
> > what will be better way to handle it ? Should such scenario be handled by
> > passing a custom http client that disables redirect  and capture error?
> >
> > If GraphQL component was built using camel-http underneath - it could
> > return many more values to make some decisions  after exchange is called
> .
> >
>
>
> --
> Claus Ibsen
>

Reply via email to