-
Notifications
You must be signed in to change notification settings - Fork 350
Description
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 Mesh 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
When using the replace-field transform, I can see the updated schema generating correctly, but the resulting query isnt getting resolved with the appropriate subfields.
To Reproduce Steps to reproduce the behavior:
The graphql endpoint returns the User object with field name of type string. The transform replaces name: String with fullName: FullName
sources:
- name: JSONPlaceholder
handler:
graphql:
endpoint: "https://graphqlplaceholder.vercel.app/graphql"
transforms:
- replace-field:
typeDefs: ./typeDefs/user.name.graphql
replacements:
- from:
type: User
field: name
to:
type: NewUser
field: fullName
additionalResolvers:
- ./resolvers/user.ts
additionalTypeDefs:
- ./typeDefs/user.graphql
/typeDefs/user.name.graphql
type FullName {
first: String
last: String
}
type NewUser {
fullName: FullName
}
/typeDefs/user.graphql
extend type User {
age: Int
}
/resolvers/user.ts
import { faker } from "@faker-js/faker";
export default {
User: {
name: () => ({
first: faker.person.firstName(),
last: faker.person.lastName(),
}),
age: () => faker.number.int({ min: 18, max: 65 }),
},
};
Running the query fails with message "Field \"name\" must not have a selection since type \"String\" has no subfields.",
query Users {
users {
id
email
name {
first
last
}
age
}
}
If I replace FullName with JSON, the resolution works correctly
/typeDefs/user.name.graphql
scalar JSON
type NewUser {
fullName: JSON
}
Expected behavior
The defined resolver is being applied properly to the GraphQLInterfaceType instance and consequently the type resolution works as intended.
Environment:
- OS:
- Mac
"@graphql-mesh/cli": "0.98.22",
"@graphql-mesh/graphql": "0.103.17",
"@graphql-mesh/transform-replace-field": "0.104.2" - NodeJS: v20
Additional context