It is a boiler plate for developing BFF and front end by schema drive.
GraphQL でスキーマ駆動開発導入したら開発効率がアップするぞ!! - Qiita
$ cd client
$ npm install
$ npm start
$ cd server
$ npm install
$ npm run mock
It is managed by common / graphql / schema.graphql
. Generate types
andhooks
based on this schema.
$ cd common
$ npm install
$ npm run gen
Generated on client and server respectively.
client/gen/actions.tsx
server/gen/types.ts
import * as React from "react";
import { useUsersQuery } from "src/gen/actions";
import Loading from "src/components/atoms/Loading";
const Content: React.FunctionComponent<{}> = () => {
const { data, loading } = useUsersQuery();
if (loading) return <Loading fetching={loading} />;
if (data && data.users) {
return (
<React.Fragment>
{data.users.map((e, key) => {
return (
<div key={key}>
<p>{e.name}</p>
</div>
);
})}
</React.Fragment>
);
}
return null;
};
export default Content;