Added Directus System Endpoint and displaying files
This commit is contained in:
8
.wundergraph/operations/Files.graphql
Normal file
8
.wundergraph/operations/Files.graphql
Normal file
@ -0,0 +1,8 @@
|
||||
query {
|
||||
system_db_files {
|
||||
id
|
||||
title
|
||||
type
|
||||
filename_disk
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
query Projects {
|
||||
directus_projects {
|
||||
query {
|
||||
db_projects {
|
||||
id
|
||||
text
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
query Todos {
|
||||
directus_todos {
|
||||
query {
|
||||
db_todos {
|
||||
id
|
||||
task
|
||||
user_created {
|
||||
|
@ -6,15 +6,20 @@ export default createOperation.query({
|
||||
address: z.string(),
|
||||
}),
|
||||
handler: async ({ input }) => {
|
||||
console.log('Making request with input:', input); // Log the input
|
||||
|
||||
const { data } = await axios.get('https://api.gnosisscan.io/api', {
|
||||
params: {
|
||||
module: 'account',
|
||||
action: 'balance',
|
||||
address: input.address,
|
||||
tag: 'latest',
|
||||
apikey: process.env.GNOSISSCAN_API,
|
||||
// tag: 'latest',
|
||||
// apikey: process.env.GNOSISSCAN_API,
|
||||
},
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
console.log('Received response:', data);
|
||||
return {
|
||||
balance: parseFloat(data.result),
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
query Bookmarks {
|
||||
directus_bookmarks {
|
||||
query {
|
||||
db_bookmarks {
|
||||
id
|
||||
name
|
||||
url
|
||||
|
2365
.wundergraph/schemas/directus_system.graphql
Normal file
2365
.wundergraph/schemas/directus_system.graphql
Normal file
File diff suppressed because it is too large
Load Diff
@ -22,8 +22,16 @@ export async function fetchSchemas() {
|
||||
}
|
||||
});
|
||||
|
||||
// Fetch the GraphQL SDL schema
|
||||
const { data: systemSchema } = await axios.get(`${serverUrl}/server/specs/graphql/system`, {
|
||||
headers: {
|
||||
'Authorization': process.env.DIRECTUS
|
||||
}
|
||||
});
|
||||
|
||||
// Save the schema to a file
|
||||
fs.writeFileSync('./.wundergraph/schemas/directus.graphql', schema);
|
||||
fs.writeFileSync('./.wundergraph/schemas/directus_system.graphql', systemSchema);
|
||||
}
|
||||
|
||||
fetchSchemas().catch(console.error);
|
@ -7,23 +7,32 @@ import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
const directusSchema = fs.readFileSync(path.join(path.resolve(), './schemas/directus.graphql'), 'utf8');
|
||||
const directusSystemSchema = fs.readFileSync(path.join(path.resolve(), './schemas/directus_system.graphql'), 'utf8');
|
||||
|
||||
const spaceX = introspect.graphql({
|
||||
apiNamespace: 'spacex',
|
||||
url: 'https://spacex-api.fly.dev/graphql/',
|
||||
});
|
||||
|
||||
const directus = introspect.graphql({
|
||||
apiNamespace: 'directus',
|
||||
const db = introspect.graphql({
|
||||
apiNamespace: 'db',
|
||||
loadSchemaFromString: directusSchema,
|
||||
url: 'https://directus.andert.me/graphql',
|
||||
headers: (builder) => builder
|
||||
.addStaticHeader('Authorization', new EnvironmentVariable('DIRECTUS', process.env.DIRECTUS))
|
||||
});
|
||||
|
||||
const system_db = introspect.graphql({
|
||||
apiNamespace: 'system_db',
|
||||
loadSchemaFromString: directusSystemSchema,
|
||||
url: 'https://directus.andert.me/graphql/system',
|
||||
headers: (builder) => builder
|
||||
.addStaticHeader('Authorization', new EnvironmentVariable('DIRECTUS', process.env.DIRECTUS))
|
||||
});
|
||||
|
||||
// configureWunderGraph emits the configuration
|
||||
configureWunderGraphApplication({
|
||||
apis: [spaceX, directus],
|
||||
apis: [spaceX, db, system_db],
|
||||
server,
|
||||
operations,
|
||||
generate: {
|
||||
|
Reference in New Issue
Block a user