movio / bramble

A federated GraphQL API gateway
https://movio.github.io/bramble/
MIT License
497 stars 53 forks source link

Bramble fails to read scheme #200

Closed codedge closed 1 year ago

codedge commented 1 year ago

Bramble does not start and fails with this error message error decoding response: invalid character 'y' in literal true (expecting 'r' while reading the following scheme. I have this schema returned from my service either as text/plain or as application/graphql content type, but neither works.

Scheme

type Query {
  node(id: ID!): Node
  aggregate(id: ID!): Aggregate
}

"A node, according to the Relay specification."
interface Node {
  "The id of this node."
  id: ID!
}

type Aggregate implements Node {
  id: ID!
  _id: String!
  totalAmount: Int
  status: String!
}

type Mutation {
  "Creates a Aggregate."
  createAggregate(input: createAggregateInput!): createAggregatePayload
}

"Creates a Aggregate."
input createAggregateInput {
  totalAmount: Int
  status: String!
  clientMutationId: String
}

"Creates a Aggregate."
type createAggregatePayload {
  aggregate: Aggregate
  clientMutationId: String
}
2023-03-13_22 35 18

I am running bramble via Docker Compose like this:

docker-compose.yml

version: '3.9'

services:
    # other...

    graphql-gateway:
        build: https://github.com/movio/bramble.git#main
        image: graphql-gateway
        environment:
            - BRAMBLE_SERVICE_LIST=http://php:80/api/graphql/schema

Isn't my scheme valid or can somebody spot an issue?

nmaquet commented 1 year ago

@codedge It looks like your BRAMBLE_SERVICE_LIST value is incorrect; you should replace the value with http://php:80/api/graphql so that Bramble can run the following query:

query {
  service {
    name
    version
    schema
  }
}

As you can see, the schema shouldn't be returned directly, but as a string field as part of the graphql response. This is why you're getting error decoding response: invalid character 'y' in literal true (expecting 'r': Bramble expects to decode a JSON response and is getting the GraphQL schema instead (it's seeing type which it isn't recognising as JSON).

See https://movio.github.io/bramble/#/getting-started?id=preparing-your-services-for-federation for more info.

codedge commented 1 year ago

Thanks for the quick answer. Very appreciated!