ardatan / ardatan/graphql-tools
Micro-server is not connected if without passing anything to args
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 830
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 45
Description
### Issue workflow progress
_Progress of the issue based on the [Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-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.

Request from server1 success.
**To Reproduce**
Steps to reproduce the behavior:
Reproducible github repo link:
https://github.com/flyingmilktea/graphql-bug-reproduce/tree/62bf26617b8c187f7a182d5b8c3846d71c4182fa
```cmd
::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
```
```ruby
query{
user {
server1Value
}
}
```
Result:
```ruby
{
"data": {
"user": null
}
}
```
**Expected behavior**
```ruby
{
"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
Contributor guide
Research direction
Run the linked graphql-bug-reproduce project using the server1 and gateway commands, then inspect packages/stitch/src/createMergedTypeResolver.ts at the referenced section. Verify the gateway query no longer returns a null user and instead produces the expected server1Value response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, node.js, typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100