I am currently using apollo to make a transfer (adding a user) on my project and when the response my object data is empty. Do you know why ?
this is my schema type
type UserKyrios {
_id: ObjectId!
firstname: String!
lastname: String!
email: String!
password: String!
creationDate: Date
}
`;
and this is my input type
input UserKyriosInput {
firstname: String!
lastname: String!
email: String!
password: String!
}
`;
Definition type Mutation
type Mutation {
upsertUserKyrios(user: UserKyriosInput!): UserKyrios
}
My querie mutation
mutation UpsertUserKyrios($user: UserKyriosInput!) {
upsertUserKyrios(user: $user) {
...userKyriosFields
creationDate
}
}
My output
data: {upsertUserKyrios: null}
upsertUserKyrios: null
My resolver
upsertUserKyrios: async (_, __, { server }) => server.plugins.mongodb.UserKyrios.insertOne(),
My script component
<script>
import { UPSERT_USER_KYRIOS } from '../../../../graphql/KyriosMutations';
export default {
name: 'addUserModalComponent',
props: {
dialog: {
type: Boolean,
default: false,
},
},
data: () => ({
user: {
firstname: '',
lastname: '',
email: '',
password: '',
},
}),
methods: {
closeDialog() {
this.$emit('closeModal');
},
async submitForm() {
const userCreated = await this.$apollo.mutate({
mutation: UPSERT_USER_KYRIOS,
variables: {
user: this.user,
},
});
console.log(userCreated);
},
},
};
</script>