Apollo client mutation error handling

后端 未结 3 1795
暖寄归人
暖寄归人 2021-01-12 06:28

I\'m using GraphQL and mongoose on the server.

When a validation error occurs the GraphQL mutation sends a response with status code 200. On the client side the resp

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 06:50

    Using graphql tag notation, yo have access to errors:

    
            {(updateTodo, { loading, error }) => (
              

    {type}

    { e.preventDefault(); updateTodo({ variables: { id, type: input.value } }); input.value = ""; }} > { input = node; }} />
    {loading &&

    Loading...

    } {error &&

    Error :( Please try again

    }
    )}

    https://www.apollographql.com/docs/react/essentials/mutations.html

提交回复
热议问题