Is there a way to pass a custom GraphQL Type with Apollo ?
e.g. : like the below, a Mutation to create an User (Custom User Type is already defined in the GraphQL schema) :
createUser(user: User): String
I think that we're only allowed to pass Primary Types, so no Object. Another option (not clean), would be to serialize an Object as a String and pass it as a String parameter, and in the resolver to deserialize it.
It is possible to pass an object in a mutation. See for example this cheat sheet. But you have to define an extra input user GraphQL type and cannot use the user type.
In your case it could look like this:
`
type User {
id: ID!
username: String!
// other query properties
}
input UserInput {
username: Strin!
}
`
And the mutation and the resolver could look like this:
`
mutation createUser(user: UserInput!): String
`
Mutation: {
createUser(_, { user }) {
// create in database
}
}