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:

On this page