I am completely new to coding but jumping into blockchain development feet first. The issue I'm having was addressed here. I tried everything mentioned, including reading through this page - getting started with Apollo Client.
However, I'm getting the same error: Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an , or pass an ApolloClient instance in via options.
Screenshot noting the problem in my code
Here's my index.js code from the top to where the error is:
import { useState } from "react";
import { ApolloClient, InMemoryCache, ApolloProvider, gql, useQuery } from "@apollo/client";
import EventCard from "../components/EventCard";
import Landing from "../components/Landing";
import client from "../apollo-client";
const UPCOMING_EVENTS = gql`
query Events($currentTimestamp: String) {
events(where: { eventTimestamp_gt: $currentTimestamp }) {
id
name
eventTimestamp
imageURL
}
}
`;
export default function Home() {
const [currentTimestamp, setEventTimestamp] = useState(
new Date().getTime().toString()
);
const { loading, error, data } = useQuery(UPCOMING_EVENTS, {
variables: { currentTimestamp },
});
Solution 1: Go back to Step 4
That didn't work. Here's proof: