Initial Wundergraph Setup
This commit is contained in:
1081
.wundergraph/schemas/directus.graphql
Normal file
1081
.wundergraph/schemas/directus.graphql
Normal file
File diff suppressed because it is too large
Load Diff
30
.wundergraph/schemas/fetch-schemas.js
Normal file
30
.wundergraph/schemas/fetch-schemas.js
Normal file
@ -0,0 +1,30 @@
|
||||
import axios from 'axios';
|
||||
import fs from 'fs';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export async function fetchSchemas() {
|
||||
|
||||
// Define the Directus server URL and credentials
|
||||
const serverUrl = 'https://directus.andert.me';
|
||||
const credentials = {
|
||||
email: process.env.EMAIL,
|
||||
password: process.env.DIRECTUS_PW
|
||||
};
|
||||
|
||||
// Login to the Directus server and get the access token
|
||||
const { data: { data: { token } } } = await axios.post(`${serverUrl}/auth/login`, credentials);
|
||||
|
||||
// Fetch the GraphQL SDL schema
|
||||
const { data: schema } = await axios.get(`${serverUrl}/server/specs/graphql`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${process.env.DIRECTUS_API}`
|
||||
}
|
||||
});
|
||||
|
||||
// Save the schema to a file
|
||||
fs.writeFileSync('./.wundergraph/schemas/directus.graphql', schema);
|
||||
}
|
||||
|
||||
fetchSchemas().catch(console.error);
|
Reference in New Issue
Block a user