-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
coreRelated to codegen core/cliRelated to codegen core/cli
Description
Heya, awesome work on this project!
I really love getting typescript defenitions for my queries but I am running into a issue with a single mutation which only returns a String!
My mutations schema look like this:
type Mutation {
authenticate(email: String!, password: String!): String!
register(email: String!, userName: String!, password: String!, password2: String!): User!
}
And in my react component:
//in register.tsx
const RegisterMutation = gql`
mutation register($email: String!, $userName: String!, $password: String!, $password2: String!) {
register(email: $email, userName: $userName, password: $password, password2: $password2) {
id
}
}
`;
//in login.tsx
const AuthenticateMutation = gql`
mutation authenticate($email: String!, $password: String!) {
authenticate(email: $email, password: $password)
}
`;
The RegisterMutation
is returning a user object where I am selecting the id
only and the defenitions gets generated correctly but for the AuthenticateMutation
I am not selecting anything because it only returns a string.
running the command below will result in a crash
gql-gen --file schema.json --template typescript --out ./typings/b.ts ./src/account/login.tsx
TypeError: Cannot read property 'fields' of undefined
at /home/dirkjan/.config/yarn/global/node_modules/graphql-code-generator/dist/handlers/inner-models-builer.js:67:29
at Array.forEach (native)
at Object.exports.buildInnerModelsArray (/home/dirkjan/.config/yarn/global/node_modules/graphql-code-generator/dist/handlers/inner-models-builer.js:11:47)
at Object.exports.handleOperation (/home/dirkjan/.config/yarn/global/node_modules/graphql-code-generator/dist/handlers/operation-handler.js:51:49)
at /home/dirkjan/.config/yarn/global/node_modules/graphql-code-generator/dist/engine/codegen.js:20:56
at Array.forEach (native)
at Object.exports.prepareCodegen (/home/dirkjan/.config/yarn/global/node_modules/graphql-code-generator/dist/engine/codegen.js:17:30)
at Transform (/home/dirkjan/.config/yarn/global/node_modules/graphql-code-generator/dist/engine/transform-engine.js:27:29)
Error: TypeError: Cannot read property 'fields' of undefined
I guess it has something to do with the fact that it returns a string instead of a object?
Metadata
Metadata
Assignees
Labels
coreRelated to codegen core/cliRelated to codegen core/cli