diff --git a/examples/with-react-relay-network-modern/.babelrc b/examples/with-react-relay-network-modern/.babelrc deleted file mode 100644 index f2926a3cc64c6..0000000000000 --- a/examples/with-react-relay-network-modern/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["next/babel"], - "plugins": [["relay", { "artifactDirectory": "__generated__" }]] -} diff --git a/examples/with-react-relay-network-modern/.env b/examples/with-react-relay-network-modern/.env deleted file mode 100644 index d54ff189f6c02..0000000000000 --- a/examples/with-react-relay-network-modern/.env +++ /dev/null @@ -1 +0,0 @@ -NEXT_PUBLIC_RELAY_ENDPOINT=https://nextjs-graphql-with-prisma-relay.vercel.app/api diff --git a/examples/with-react-relay-network-modern/.gitignore b/examples/with-react-relay-network-modern/.gitignore deleted file mode 100644 index c86f6fff985cc..0000000000000 --- a/examples/with-react-relay-network-modern/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel - -# relay -__generated__/ -schema/schema.graphql diff --git a/examples/with-react-relay-network-modern/.graphqlconfig b/examples/with-react-relay-network-modern/.graphqlconfig deleted file mode 100644 index f973e3a39dead..0000000000000 --- a/examples/with-react-relay-network-modern/.graphqlconfig +++ /dev/null @@ -1,8 +0,0 @@ -{ - "schemaPath": "schema/schema.graphql", - "extensions": { - "endpoints": { - "dev": "https://nextjs-graphql-with-prisma-relay.vercel.app/api" - } - } -} \ No newline at end of file diff --git a/examples/with-react-relay-network-modern/README.md b/examples/with-react-relay-network-modern/README.md deleted file mode 100644 index 7684104bb8e8b..0000000000000 --- a/examples/with-react-relay-network-modern/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Relay Modern Example - -[Relay Modern](https://relay.dev/) is a new version of Relay designed from the ground up to be easier to use, more extensible and, most of all, able to improve performance on mobile devices. Relay Modern accomplishes this with static queries and ahead-of-time code generation. - -This example relies on [Prisma + Nexus](https://github.com/prisma-labs/nextjs-graphql-api-examples) for its GraphQL backend. - -## Deploy your own - -Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example): - -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-react-relay-network-modern&project-name=with-react-relay-network-modern&repository-name=with-react-relay-network-modern) - -## How to use - -Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: - -```bash -npx create-next-app --example with-react-relay-network-modern with-react-relay-network-modern-app -# or -yarn create next-app --example with-react-relay-network-modern with-react-relay-network-modern-app -``` - -Download schema introspection data from configured Relay endpoint - -```bash -npm run schema -# or -yarn schema -``` - -Run Relay ahead-of-time compilation (should be re-run after any edits to components that query data with Relay) - -```bash -npm run relay -# or -yarn relay -``` - -Run the project - -```bash -npm run dev -# or -yarn dev -``` - -Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). diff --git a/examples/with-react-relay-network-modern/components/BlogPostPreview.js b/examples/with-react-relay-network-modern/components/BlogPostPreview.js deleted file mode 100644 index dd1619dbb195e..0000000000000 --- a/examples/with-react-relay-network-modern/components/BlogPostPreview.js +++ /dev/null @@ -1,14 +0,0 @@ -import { createFragmentContainer, graphql } from 'react-relay' - -const BlogPostPreview = ({ post }) => { - return
{post.title}
-} - -export default createFragmentContainer(BlogPostPreview, { - post: graphql` - fragment BlogPostPreview_post on BlogPost { - id - title - } - `, -}) diff --git a/examples/with-react-relay-network-modern/components/BlogPosts.js b/examples/with-react-relay-network-modern/components/BlogPosts.js deleted file mode 100644 index bcd3ca2944aeb..0000000000000 --- a/examples/with-react-relay-network-modern/components/BlogPosts.js +++ /dev/null @@ -1,26 +0,0 @@ -import { createFragmentContainer, graphql } from 'react-relay' -import BlogPostPreview from './BlogPostPreview' - -const BlogPosts = ({ viewer }) => ( -
-

Blog posts

- {viewer.allBlogPosts?.edges.map(({ node }) => ( - - ))} -
-) - -export default createFragmentContainer(BlogPosts, { - viewer: graphql` - fragment BlogPosts_viewer on Viewer { - allBlogPosts(first: 10, orderBy: { createdAt: desc }) { - edges { - node { - ...BlogPostPreview_post - id - } - } - } - } - `, -}) diff --git a/examples/with-react-relay-network-modern/lib/createEnvironment/client.js b/examples/with-react-relay-network-modern/lib/createEnvironment/client.js deleted file mode 100644 index ae31eaa715d19..0000000000000 --- a/examples/with-react-relay-network-modern/lib/createEnvironment/client.js +++ /dev/null @@ -1,36 +0,0 @@ -import { - RelayNetworkLayer, - cacheMiddleware, - urlMiddleware, -} from 'react-relay-network-modern/node8' -import RelaySSR from 'react-relay-network-modern-ssr/node8/client' -import { Environment, RecordSource, Store } from 'relay-runtime' - -const source = new RecordSource() -const store = new Store(source) - -let storeEnvironment = null - -export default { - createEnvironment: (relayData) => { - if (storeEnvironment) return storeEnvironment - - storeEnvironment = new Environment({ - store, - network: new RelayNetworkLayer([ - cacheMiddleware({ - size: 100, - ttl: 60 * 1000, - }), - new RelaySSR(relayData).getMiddleware({ - lookup: false, - }), - urlMiddleware({ - url: (req) => process.env.NEXT_PUBLIC_RELAY_ENDPOINT, - }), - ]), - }) - - return storeEnvironment - }, -} diff --git a/examples/with-react-relay-network-modern/lib/createEnvironment/index.js b/examples/with-react-relay-network-modern/lib/createEnvironment/index.js deleted file mode 100644 index 217178c8ade2c..0000000000000 --- a/examples/with-react-relay-network-modern/lib/createEnvironment/index.js +++ /dev/null @@ -1,5 +0,0 @@ -export const { initEnvironment, createEnvironment } = (typeof window === -'undefined' - ? require('./server') - : require('./client') -).default diff --git a/examples/with-react-relay-network-modern/lib/createEnvironment/server.js b/examples/with-react-relay-network-modern/lib/createEnvironment/server.js deleted file mode 100644 index 72f162996826b..0000000000000 --- a/examples/with-react-relay-network-modern/lib/createEnvironment/server.js +++ /dev/null @@ -1,36 +0,0 @@ -import { - RelayNetworkLayer, - urlMiddleware, -} from 'react-relay-network-modern/node8' -import RelaySSR from 'react-relay-network-modern-ssr/node8/server' -import { Network, Environment, RecordSource, Store } from 'relay-runtime' - -export default { - initEnvironment: () => { - const source = new RecordSource() - const store = new Store(source) - const relaySSR = new RelaySSR() - - return { - relaySSR, - environment: new Environment({ - store, - network: new RelayNetworkLayer([ - urlMiddleware({ - url: (req) => process.env.NEXT_PUBLIC_RELAY_ENDPOINT, - }), - relaySSR.getMiddleware(), - ]), - }), - } - }, - createEnvironment: (relayData) => { - const source = new RecordSource() - const store = new Store(source) - - return new Environment({ - store, - network: Network.create(() => relayData?.[0][1] || Promise.resolve()), - }) - }, -} diff --git a/examples/with-react-relay-network-modern/package.json b/examples/with-react-relay-network-modern/package.json deleted file mode 100644 index 32695eafc3236..0000000000000 --- a/examples/with-react-relay-network-modern/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "with-react-relay-network-modern", - "version": "3.0.3", - "description": "Example of Next.js with Relay Modern and react-relay-network-modern", - "scripts": { - "dev": "next", - "build": "next build", - "start": "next start", - "relay": "relay-compiler --src ./ --exclude '**/.next/**' '**/node_modules/**' '**/test/**' '**/__generated__/**' --exclude '**/schema/**' --schema ./schema/schema.graphql --artifactDirectory __generated__", - "schema": "graphql get-schema -e dev" - }, - "author": "", - "license": "MIT", - "dependencies": { - "graphql": "^14.6.0", - "next": "latest", - "react": "^16.13.0", - "react-dom": "^16.13.0", - "react-relay": "^9.0.0", - "react-relay-network-modern": "^4.5.0", - "react-relay-network-modern-ssr": "^1.4.0", - "relay-hooks": "3.5.2" - }, - "devDependencies": { - "babel-plugin-relay": "^9.0.0", - "graphql-cli": "^3.0.11", - "relay-compiler": "^9.0.0" - } -} diff --git a/examples/with-react-relay-network-modern/pages/_app.js b/examples/with-react-relay-network-modern/pages/_app.js deleted file mode 100644 index 5709ef97a1fc6..0000000000000 --- a/examples/with-react-relay-network-modern/pages/_app.js +++ /dev/null @@ -1,13 +0,0 @@ -import { RelayEnvironmentProvider } from 'relay-hooks' - -import { createEnvironment } from '../lib/createEnvironment' - -export default function App({ Component, pageProps }) { - return ( - - - - ) -} diff --git a/examples/with-react-relay-network-modern/pages/index.js b/examples/with-react-relay-network-modern/pages/index.js deleted file mode 100644 index 917e329c70e13..0000000000000 --- a/examples/with-react-relay-network-modern/pages/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import { graphql, fetchQuery } from 'react-relay' -import { useQuery } from 'relay-hooks' - -import { initEnvironment } from '../lib/createEnvironment' -import BlogPosts from '../components/BlogPosts' - -const query = graphql` - query pages_indexQuery { - viewer { - ...BlogPosts_viewer - } - } -` - -const Index = ({ environment }) => { - const { error, props } = useQuery(query) - - if (error) return
{error.message}
- - if (!props) return
Loading
- - return -} - -export async function getStaticProps() { - const { environment, relaySSR } = initEnvironment() - - await fetchQuery(environment, query) - - const relayData = (await relaySSR.getCache())?.[0] - - return { - props: { - relayData: !relayData ? null : [[relayData[0], relayData[1].json]], - }, - } -} - -export default Index