ardatan / ardatan/graphql-tools

@graphql-tools/wrap: Nested variable input types are not treated as input types

Open
#4,300 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
830
Avg merge
10h 59m
Merged PRs (30d)
45

Description

**Describe the bug**

When calling `wrapSchema` on a schema, the resulting schema breaks when input types provided by a variable are nested inside input types provided in the query directly, with an error message that goes like `Variable "$input" expected value of type "DefinitelyAnInputType!" which cannot be used as an input type.`. You can see the message in the repro below. When `wrapSchema` is removed, it works perfectly fine.

**To Reproduce**
Steps to reproduce the behavior:

- https://codesandbox.io/s/tender-bohr-f25yrt

I couldn't narrow this down to a version or a commit. It looks like GraphQL's `isInputType` is returning `true` for these types, so I have no idea where this error is coming from at all.

**Expected behavior**

For it to behave like the original schema (i.e. not throw an error).

**Environment:**

- OS: Any
- `@graphql-tools/schema`: 8.3.2
- `@graphql-tools/wrap`: 8.4.3
- `graphql`: 16.3.0
- NodeJS: 16

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure in the linked CodeSandbox with wrapSchema, then compare it with the same schema without wrapping. Trace how @graphql-tools/wrap handles nested variable input types and verify that the wrapped schema behaves like the original without throwing the reported input-type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, node.js, typescript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.