Question: I need help with a react Graphql project to fetch data from this endpoint: https://squid.subsquid.io/subsocial/graphql index.js import Head from 'next/head' import { ApolloClient, InMemoryCache, gql
I need help with a react Graphql project to fetch data from this endpoint: https://squid.subsquid.io/subsocial/graphql
index.js
import Head from 'next/head' import { ApolloClient, InMemoryCache, gql } from '@apollo/client'; import styles from '../styles/Home.module.css'
export default function Home({ launches }) { return (
SpaceX Launches
Latest launches from SpaceX
{ post.title }
Followers Count { new Date(post.reactionsCount) }
); })}
export async function getStaticProps() { const client = new ApolloClient({ uri: 'https://squid.subsquid.io/subsocial/graphql', cache: new InMemoryCache() });
const { data } = await client.query({ query: gql` query myQuery { post (orderBy: reactionsCount_DESC, limit: 3, where: {createdAtTime_gt: "2023-01-01T00:00:00.000000Z"}) { content title reactionsCount sharedPost { id } createdAtTime space { id name summary } } } ` });
return { props: { reactions: data.post } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
