simple
This commit is contained in:
38
src/index.ts
38
src/index.ts
@@ -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)))
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user