Closed harsh-solutelabs closed 3 years ago
you would need to create a custom adapter which implements BaseResource. Take a look at how admin-bro-mongoose is done: https://github.com/SoftwareBrothers/admin-bro-sequelizejs/blob/master/src/resource.js
then you can pass this resource to options like this:
const MyResource = require('path-to-my-resource')
const AdminBroOptions = {
resources: [new MyResource(...params_passed_to_your_constructor)]
}
How I can use that graphql API in a custom component because to call that mutation I want to wrap the custom component with Appollo server?
Unfortunately, I don't have any experience with apollo and react so I cannot help you :(
client.jsx
import ApolloClient, { InMemoryCache } from 'apollo-boost';
export default new ApolloClient({
headers: {
Authorization:'Bearer sometoken'
},
uri: 'graphql end point',
cache: new InMemoryCache(),
});
dashboard.jsx
import React from 'react';
import Demo from './demo';
import { ApolloProvider } from 'react-apollo';
import client from './client';
const Dashboard = props => {
return (
<ApolloProvider client={client}>
<Demo />
</ApolloProvider>
);
};
export default Dashboard;
demo.jsx
import React from "react";
import {useQuery} from "react-apollo";
const Demo = props => {
const {data,loading,error} = useQuery(SOME_QUERY);
if(data){
console.log(data);
}
return (
<p>Hello world</p>
);
};
export default Demo;
@wojtek-krysiak we can use this approach to connect with GraphQl :)
we have hasura integration in the backlog #655 (WIP)
Is there any way to integrate graphql API with the admin panel?