mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
parent
708193d227
commit
ed0c144af9
8
examples/with-relay-modern/.graphqlconfig
Normal file
8
examples/with-relay-modern/.graphqlconfig
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"schemaPath": "schema/schema.graphql",
|
||||||
|
"extensions": {
|
||||||
|
"endpoints": {
|
||||||
|
"dev": "https://api.graph.cool/relay/v1/next-js-with-relay-modern-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,15 +16,10 @@ Install it:
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
Setup Graphcool project
|
Download schema introspection data from configured Relay endpoint
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run graphcool-init
|
npm run schema
|
||||||
```
|
|
||||||
|
|
||||||
After successful initialization, copy Graphcool Relay Endpoint URL from console and store it into `.env` file
|
|
||||||
```bash
|
|
||||||
RELAY_ENDPOINT=your relay endpoint here
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Run Relay ahead-of-time compilation (should be re-run after any edits to components that query data with Relay)
|
Run Relay ahead-of-time compilation (should be re-run after any edits to components that query data with Relay)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Environment, Network, RecordSource, Store } from 'relay-runtime'
|
import { Environment, Network, RecordSource, Store } from 'relay-runtime'
|
||||||
import fetch from 'isomorphic-unfetch'
|
import fetch from 'isomorphic-fetch'
|
||||||
|
|
||||||
let relayEnvironment = null
|
let relayEnvironment = null
|
||||||
|
|
||||||
|
|
|
@ -8,20 +8,21 @@
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"relay": "relay-compiler --src ./ --exclude **/.next/** **/node_modules/** **/test/** **/__generated__/** --schema ./schema/schema.graphql",
|
"relay": "relay-compiler --src ./ --exclude **/.next/** **/node_modules/** **/test/** **/__generated__/** --schema ./schema/schema.graphql",
|
||||||
"schema": "node scripts/getSchema.js"
|
"schema": "graphql get-schema dev"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"dotenv-webpack": "^1.5.4",
|
"dotenv-webpack": "^1.5.4",
|
||||||
"isomorphic-unfetch": "^2.0.0",
|
"isomorphic-fetch": "^2.2.1",
|
||||||
"next": "^3.0.3",
|
"next": "^3.0.3",
|
||||||
"react": "^15.6.1",
|
"react": "^15.6.1",
|
||||||
"react-dom": "^15.6.1",
|
"react-dom": "^15.6.1",
|
||||||
"react-relay": "^1.2.0-rc.1"
|
"react-relay": "^1.2.0-rc.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"graphql-cli": "^1.0.0-beta.4",
|
||||||
"babel-plugin-relay": "^1.1.0",
|
"babel-plugin-relay": "^1.1.0",
|
||||||
"graphcool": "^1.2.1",
|
"graphcool": "^1.2.1",
|
||||||
"relay-compiler": "^1.2.0-rc.1"
|
"relay-compiler": "^1.2.0-rc.1"
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
var fetch = require('node-fetch')
|
|
||||||
var fs = require('fs')
|
|
||||||
var path = require('path')
|
|
||||||
|
|
||||||
require('dotenv').config()
|
|
||||||
|
|
||||||
const {
|
|
||||||
buildClientSchema,
|
|
||||||
introspectionQuery,
|
|
||||||
printSchema
|
|
||||||
} = require('graphql/utilities')
|
|
||||||
|
|
||||||
console.log(introspectionQuery)
|
|
||||||
|
|
||||||
fetch(process.env.RELAY_ENDPOINT, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ 'query': introspectionQuery })
|
|
||||||
})
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(res => {
|
|
||||||
console.log(res)
|
|
||||||
const schemaString = printSchema(buildClientSchema(res.data))
|
|
||||||
fs.writeFileSync(path.join(__dirname, '..', 'schema', 'schema.graphql'), schemaString)
|
|
||||||
})
|
|
Loading…
Reference in a new issue