Skip to content

Doubt using graphql type resolvers for more than one query #12

@rakshith1994

Description

@rakshith1994

Hi scott , my name is rakshith and i had attended your server side graphql in nodejs online course on frontend masters. I had this doubt on resolvers.

There are 2 object types -

User { email , name, post : Post}

Post {body, user: User }

I have 2 mutations - addPost and deletePost

I have written a resolver to addPost , basically it creates a new post in collection. Then i used the type resolver user from post type to fetch user data.

Now in the 2 mutation deletePost . I have written a resolver to delete a post using the id, and i am then trying to use the type resolver from post type that is user to remove the reference of tht post from the user.

The problem here is.. the type resolver user is already fetching me a user data for the earlier addPost mutation. How will i tell it to only run a query that would delete the reference from the user, and not fetch a user?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions