yarn add graphql graphql-yoga
cd pages/api && touch graphql.ts
import { createYoga, createSchema } from "graphql-yoga";
export default createYoga<any>({
schema: createSchema({ typeDefs, resolvers }),
graphqlEndpoint: "/api/graphql",
});
yarn add @apollo/client
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";
const client = new ApolloClient({
uri: "/api/graphql",
cache: new InMemoryCache(),
});
function MyApp({ Component, pageProps }: AppProps) {
return (
<ApolloProvider client={client}>
<Component {...pageProps} />
</ApolloProvider>
);
}