CLUI GraphQL
@replit/clui-gql
is a small utility that transforms GraphQL introspection data for a type into commands.
Install
npm install @replit/clui-gql
Usage
import { toCommand } from '@replit/clui-gql';
const command = toCommand({
operation: 'query',
type: TypeInfo,
mountPath: ['cli', 'admin'],
runFn: (gqlOptions) => (runOptions) => doSomehtingWith({ gqlOptions, runOptions }),
outputFn: () => ({
fields: '...Output',
fragments: `
fragment Output on YourOutputTypes {
...on SuccessOutput {
message
}
...on ErrorOutput {
error
}
}`,
}),
});