This commit is contained in:
2025-02-18 12:30:47 +08:00
parent 90f4cfa6ee
commit ae97dc0a5f
12 changed files with 16 additions and 55 deletions

View File

@@ -1,34 +1,8 @@
import { ofetch } from 'ofetch';
import gql from 'graphql-tag'
import { print } from 'graphql';
/** GraphQL */
const gqlText = print(gql(`
query get {
demo_projects {
id
}
}`
));
console.log(gqlText);
// const gqlText = gql(
// `query {w
import type { GetUserProjectsQuery, GetUserProjectsQueryVariables } from "../graphql/__generated__/graphql"
import { graphqlClient } from "./graphql-client"
import { getUserProjectsGQL } from "./gql"
(async () => {
const result = await ofetch("http://172.16.6.246:8055/graphql", {
method: 'POST',
headers: {
'Authorization': 'Bearer WkVWFMiFcrjsXRZqsL30Cd4Sboe0DRk-',
'Content-Type': 'application/json',
},
body: {
query: gqlText,
variables: {}
},
})
console.log(JSON.stringify(result, null, 2));
})();
const result = await graphqlClient.request<GetUserProjectsQuery, GetUserProjectsQueryVariables>(getUserProjectsGQL)
console.log(result.demo_users.map(user => user?.projects?.map(project => project?.demo_projects_id)))
})()