import React, { useEffect, useState } from 'react'; import { ApolloClient, InMemoryCache, ApolloProvider, gql, useQuery } from '@apollo/client'; // 1. Initialize Apollo Client const client = new ApolloClient({ uri: 'https://countries.trevorblades.com/', // Example public GraphQL API cache: new InMemoryCache(), }); // 2. Define your GraphQL query const GET_CONTINENTS = gql` query GetContinents { continents { code name } } `; // 3. Create a React component to display the data function ContinentsList() { const { loading, error, data } = useQuery(GET_CONTINENTS); if (loading) return
Loading continents...
; if (error) returnError: {error.message}
; return (