Skip to content

type-graphql update mutation with typegoose #953

Discussion options

You must be logged in to vote

After multiple attempts I got it working:

@Mutation(() => Boolean, { nullable: false })
    async updatePosition(
      @Arg("positionId", type => ObjectIdScalar) positionId: ObjectId,
      @Arg("position", () => PositionInput, { nullable: true }) positionInput: PositionInput
      ) {
        
        const position = await PositionModel.findOneAndUpdate({
            _id: positionId as any
        }, positionInput);

        if (position)
           return true;
        else return false;
    }

I have not changed anything in the PositionInput.
Thank you for your time @MichalLytek !

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Sed9yDataBank
Comment options

Comment options

You must be logged in to vote
1 reply
@stemount
Comment options

Answer selected by Sed9yDataBank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants