I don't know much about relay-fullstack but if your only problem is generating the schema file provided in the tutorial, just check how it is generated: https://github.com/relayjs/relay-starter-kit/blob/master/scripts/updateSchema.js
With the latest version of graphql (or graphql-sync) the introspectionQuery
and printSchema
utilities are exported from the package directly.
You can emulate the updateSchema
script in Foxx by creating a new Foxx script called update-schema
:
First add the script to your manifest:
"scripts": {
"update-schema": "scripts/updateSchema.js"
}
Then implement the script itself as scripts/updateSchema.js
like so (assuming your GraphQL schema lives in data/schema.js
):
'use strict'
const fs = require('fs')
const path = require('path')
const Schema = require('../data/schema')
const gql = require('graphql')
const result = gql.graphql(Schema, gql.introspectionQuery)
if (result.errors) {
console.error(
'ERROR introspecting schema: ',
JSON.stringify(result.errors.map((err) => gql.formatError(err)), null, 2)
)
} else {
fs.writeFileSync(
path.join(__dirname, '../data/schema.json'),
JSON.stringify(result, null, 2)
)
}
fs.writeFileSync(
path.join(__dirname, '../data/schema.graphql'),
gql.printSchema(Schema)
)
You can now run the script from the web interface by going into the settings tab of your service and picking it from the dropdown (you don't need to pass any arguments, just press OK). The script should generate the two JSON and GraphQL files for your schema like the one in the starter kit does.