graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

Micro-server is not connected if without passing anything to args

Open Abbywpy opened this issue 3 years ago • 0 comments
trafficstars

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • [ ] 2. A failing test has been provided
  • [ ] 3. A local solution has been provided
  • [ ] 4. A pull request is pending review

Describe the bug

Subschemas is stitched with gateway schema and show in schema, however the request from gateway fails and return null result.

image

Request from server1 success.

image

To Reproduce Steps to reproduce the behavior:

Reproducible github repo link: https://github.com/flyingmilktea/graphql-bug-reproduce/tree/62bf26617b8c187f7a182d5b8c3846d71c4182fa

::start server1
cd server1
npm i
pip install awscli aws-sam-cli
sam local start-api -t ./local.yml -l message.log --host 0.0.0.0 -p 3000

::start gateway server
cd gateway
npm i
sam local start-api -t ./local.yml -l message.log --host 0.0.0.0 -p 3001
query{
  user {
    server1Value
  }
}

Result:

{
  "data": {
    "user": null
  }
}

Expected behavior

{
  "data": {
    "user": {
      "server1Value": "User server1: 2022-06-07T04:04:46.730Z"
    }
  }
}

Environment:

  • OS: Arch Linux 5.15.44-1-lts Mon, 30 May 2022 13:45:47
  • "@graphql-tools/graphql-file-loader": "^7.3.14",
  • "@graphql-tools/load": "^7.5.13",
  • "@graphql-tools/schema": "^8.3.13",
  • "@graphql-tools/stitch": "^8.6.12",
  • "@graphql-yoga/node": "^2.8.0",
  • "@vendia/serverless-express": "^4.8.0",
  • "axios": "^0.27.2",
  • "graphql-scalars": "^1.17.0",
  • "lodash": "^4.17.21",
  • "mem": "^8.1.1"
  • NodeJS: v14.19.3

Additional context

https://github.com/ardatan/graphql-tools/blob/bccf6591cbedd69084d5abb8e35ec07f2a4267b3/packages/stitch/src/createMergedTypeResolver.ts#L5-L61

The problem could be workaround by passing undefined to args or argsFromKeys, and it's likely caused by no default case under createMergedTypeResolver for both args and argsFromKeys are null.

This may simply solve by:

const { fieldName, argsFromKeys, valuesFromResults, args= ()=>({}) } = mergedTypeResolverOptions;

Thanks @kftsehk for helping provide solution

Abbywpy avatar Jun 07 '22 04:06 Abbywpy