1. Setup
Let's install the packages we need:
npm install @whalecloud/dx-fr-api
GraphQLClient
2. learn @whalecloud/dx-fr-api
use @fishx/graphql-client
GraphQLClient
3. Initialize import React from 'react';
import { render } from 'react-dom';
import {
useDxGraphQLClient,
DxApiConatiner
} from "@whalecloud/dx-fr-api";
import { GraphQLClient } from '@fishx/graphql-client';
import axios from 'axios';
export const defRequest = axios.create({
timeout: 10000,
baseURL: '/portal/api',
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
});
export const defClient = new GraphQLClient('/portal/api/graphql', {
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
});
function App() {
// 使用
// const client = useDxGraphQLClient();
return (
<div>
<h2>My first GraphQL app 🚀</h2>
</div>
);
}
render(
<DxApiConatiner client={client}>
<App />
</DxApiConatiner>,
document.getElementById('root'),
);