Skip to content

igor-ag5/graphql-mesh-grpc-defaults-bug-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

GraphQL Mesh gRPC defaults bug demo

This project demonstrates a bug in the GraphQL Mesh where the option to load the default gRPC values does not have any effect.

Reproduce the issue

Run Demo gRPC service

  • navigate to the demo_service folder
  • run go mod download to download dependencies
  • run make start to start the gRPC service

Run GraphQL Mesh

  • open a second terminal
  • navigate to the mesh folder
  • run yarn install
  • run yarn start-mesh

Example query

  • navigate to http://localhost:4000/graphql
  • run the following query:
{
  DemoService_GetSomeData(input: {}) {
    data {
      someTextData,
      someEnum
    }
  }
}

The response:

{
  "data": {
    "DemoService_GetSomeData": {
      "data": [
        {
          "someTextData": "data 0",
          "someEnum": null
        },
        {
          "someTextData": "data 1",
          "someEnum": "ENUM_ONE"
        }
      ]
    }
  }
}

The issue Please note that the first someEnum value is null. The gRPC service is responding with ENUM_ZERO (the default value) and therefore this response is expected with the default configuration. Nevertheless, when the mesh configuration specifies the load defaults option:

    - name: DemoService
      handler:
        grpc:
          endpoint: localhost:9003
          source:
            load:
              defaults: true
            file: ../service_go/service_proto/demo_service.proto

Then the expected behavior is to fill the value with the default value and the expected response would be:

{
  "data": {
    "DemoService_GetSomeData": {
      "data": [
        {
          "someTextData": "data 0",
          "someEnum": "ENUM_ZERO"
        },
        {
          "someTextData": "data 1",
          "someEnum": "ENUM_ONE"
        }
      ]
    }
  }
}

However, currently this is not the case and the configuration does not have any effect.

About

Showcases bug in the graphql mesh load options

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published