I'm trying to execute a mutation query that requires a custom input type on the client. Currently it looks something like this:
import { graphql } from 'react-apollo';
...
const graphQuery = graphql(gql`
input UserSignUpInput {
firstName: String!,
lastName: String!,
email: String!,
password: String!
}
mutation userSignUp($input: UserSignUpInput!) {
createUserByEmail(input: $input) {
authToken
}
}`, {
props: ({ mutate }) => ({
signup: (firstName, lastName, email, password) =>
mutate({ variables: { input: { firstName, lastName, email, password } } }),
}),
});
...
However I'm getting the error that I'm not allowed to define input types in the query. My question is: How do I define these complex input types? It doesn't seem like I'm able to provide a Schema to ApolloClient..
The correct syntax on the client side is just:
gql`
mutation userSignUp($input: UserSignUpInput!) {
createUserByEmail(input: $input) {
authToken
}
}
`
As your input UserSignUpInput is defined on the server, everything is going fine.
server
input UserSignUpInput {
firstName: String!,
lastName: String!,
email: String!,
password: String!
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With