Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks
Tracked by #5201 ...
Abbywpy opened this issue Jun 7, 2022 · 0 comments
Open
4 tasks
Tracked by #5201 ...

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

Abbywpy opened this issue Jun 7, 2022 · 0 comments

Comments

@Abbywpy
Copy link

Abbywpy commented Jun 7, 2022

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

export function createMergedTypeResolver<TContext extends Record<string, any> = any>(
mergedTypeResolverOptions: MergedTypeResolverOptions
): MergedTypeResolver<TContext> | undefined {
const { fieldName, argsFromKeys, valuesFromResults, args } = mergedTypeResolverOptions;
if (argsFromKeys != null) {
return function mergedBatchedTypeResolver(
_originalResult,
context,
info,
subschema,
selectionSet,
key,
type = getNamedType(info.returnType) as GraphQLOutputType
) {
return batchDelegateToSchema({
schema: subschema,
operation: 'query' as OperationTypeNode,
fieldName,
returnType: new GraphQLList(type),
key,
argsFromKeys,
valuesFromResults,
selectionSet,
context,
info,
skipTypeMerging: true,
});
};
}
if (args != null) {
return function mergedTypeResolver(
originalResult,
context,
info,
subschema,
selectionSet,
_key,
type = getNamedType(info.returnType) as GraphQLOutputType
) {
return delegateToSchema({
schema: subschema,
operation: 'query' as OperationTypeNode,
fieldName,
returnType: type,
args: args(originalResult),
selectionSet,
context,
info,
skipTypeMerging: true,
});
};
}
return undefined;
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant