Developer Docs

What is Apollo?

When exploring the C#Bot Technology List: Server-Side used by C#Bot, we discussed how we use GraphQL to query the database. On the client-side, Apollo facilitates communication with GraphQL API, which is presented by the server-side. In essence, Apollo is an implementation of the GraphQL specification, and a way of binding data to the User Interface using GraphQL.

An example usage of Apollo is shown below:

function useLoading<T>(request: DocumentNode) {
    const [loading, setLoading] = useState(true);
    const [error, setError] = useState("");
    const [data, setData] = useState<T>();

    useEffect(() => {
        store.apolloClient
            .query<T>({ query: request })
            .then((d) => {
                console.log(d);
                setLoading(false);
                setData(d.data);
            })
            .catch((e) => {
                console.log(e);
                setLoading(false);
                setError(e);
            });
    }, [request]);

    return { loading, error, data };
}

Learn more:

Was this article helpful?

Thanks for your feedback!

If you would like to tell us more, please click on the link below to send us a message with more details.

Tool:

Generate

Iterate

Bot:

C#Bot

SpringBot

On this page

New to Codebots?

We know our software can be complicated, so we are always happy to have a chat if you have any questions.