Search code examples
react-nativeaws-lambdagraphqlapollo-client

GraphQL - Apollo Client without using hooks?


I am attempting to use the Apollo GraphQL Client for React Native. However, in some parts of my app I need to do a mutation on the GraphQL data, in such a way that the interface should not be exposed to the user.

For instance, on my sign up page, I want to create a user in the database, but only after I have gone through and verified everything, created a uuid, etc. (things that require a class). If the call is sucessful, I want to imediately move on to the home page of the app. If not, I want to notify the user.

As such, I need access to do a GraphQL request, without hooks and just using callbacks to change the UI. Is this possible, and how could this be done?


Solution

  • Yes, its possible.

    A call to the GraphQL service simply expects a key-value pair of query or mutation in the body with the query/mutation you're trying to send.

    You can do this with a simple fetch request as POST, or a cURL, or via postman... It doesn't really matter as long as its a POST request.

    See also here.