### Start Next.js Development Server Source: https://github.com/sporeprotocol/spore-graphql/blob/master/example/README.md Commands to initiate the local development server for a Next.js application, supporting npm, yarn, pnpm, and bun package managers. The server will typically run on `http://localhost:3000`. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Install spore-graphql dependency Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md Instructions to install `spore-graphql` and `@spore-sdk/core` using npm as a package manager. ```shell npm install spore-graphql @spore-sdk/core --save ``` -------------------------------- ### Integrate Spore GraphQL server into Next.js API route Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md Example of setting up the Spore GraphQL server handler in a Next.js API route, using `startSporeServerNextHandler` and `predefinedSporeConfigs`. ```typescript // app/api/graphql/route.js import { startSporeServerNextHandler } from 'spore-graphql/next'; import { predefinedSporeConfigs } from '@spore-sdk/core'; const handler = startSporeServerNextHandler(predefinedSporeConfigs.Aggron4); export { handler as GET, handler as POST }; ``` -------------------------------- ### Get mintable clusters by CKB address (GraphQL) Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md GraphQL query to find clusters that are mintable by a specific CKB address, returning their ID, name, and description. ```graphql query GetMintableClusters { clusters( filter: { mintableBy: "ckt1qrejnmlar3r452tcg57gvq8patctcgy8acync0hxfnyka35ywafvkqgpwrcql790ua7gr9kam255sq3ussa09wtgqqjwqus2" } ) { id name description } } ``` -------------------------------- ### Get Spores by content type (GraphQL) Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md GraphQL query to filter and retrieve Spores based on their content type, specifically 'text/markdown'. ```graphql query GetMarkdownContentTypeSpores { spores(filter: { contentTypes: ["text/markdown"] }) { id contentType } } ``` -------------------------------- ### Configure Spore GraphQL with Redis Cache Backend Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md This TypeScript example demonstrates how to set up a cache backend for a spore-graphql server using `KeyvAdapter` with a Redis instance. It includes `ApolloServerPluginCacheControl` for default max age and `responseCachePlugin` for response caching, ensuring efficient handling of GraphQL queries. ```typescript import { startSporeServerNextHandler } from 'spore-graphql/next'; import responseCachePlugin from '@apollo/server-plugin-response-cache'; import { ApolloServerPluginCacheControl } from '@apollo/server/plugin/cacheControl'; import { KeyvAdapter } from '@apollo/utils.keyvadapter'; import Keyv from 'keyv'; import { predefinedSporeConfigs } from '@spore-sdk/core'; export const fetchCache = 'force-no-store'; export const maxDuration = 300; const cache = new KeyvAdapter(new Keyv("redis://...")); const handler = startSporeServerNextHandler(predefinedSporeConfigs.Aggron4, { cache, plugins: [ ApolloServerPluginCacheControl({ defaultMaxAge: 60 * 60 * 24, }), responseCachePlugin(), ], }, }); export { handler as GET, handler as POST }; ``` -------------------------------- ### Get top clusters by spore count (GraphQL) Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md GraphQL query to retrieve top clusters, sorted by the number of associated spores, including their name, ID, and description. ```graphql query GetTopClustersQuery { topClusters { name id description } } ``` -------------------------------- ### Get Spore by ID with cluster details (GraphQL) Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md GraphQL query to fetch a specific Spore by its ID, including its content type, content, and associated cluster's details. ```graphql query GetSporeById { spore(id: "0x95e5d57b6a9b2b35f26a8ade93e48ed736283ca2ca860654b809f8a1b9b8c8eb") { id contentType content cluster { id name description } } } ``` -------------------------------- ### Fetch Spore data using a GraphQL client Source: https://github.com/sporeprotocol/spore-graphql/blob/master/README.md Demonstrates how to use `graphql-request` to fetch the first 10 spores and their cluster names from the Spore GraphQL API. ```typescript import { request, gql } from 'graphql-request' // Get the first 10 spores and their cluster names const document = gql` { spores { id contentType cluster { name } } } ` await request('/api/graphql/', document) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.