I like using the got
npm package to post the schema.
const importSchema = async (faunadbKey, schema) => {
try {
const response = await got.post(
`https://graphql.fauna.com/import`,
{
body: schema,
headers: {
Authorization: `Bearer ${faunadbKey}`,
},
}
)
if (response.statusCode !== 200) {
throw new Error(response.body)
}
return response.body
} catch (error) {
return error.response.body
}
}
I’ve wrapped that in a package that you can use, or just copy the code from: