-
Notifications
You must be signed in to change notification settings - Fork 16
configure your "Form component"
Charly POLY edited this page Jun 6, 2018
·
1 revision
react-apollo-form
expose a configure(options)
function with the following options:
interface ApolloFormConfigureOptions {
client: ApolloClient<any>;
jsonSchema: JSONSchema6;
theme?: ApolloFormConfigureTheme;
}
-
client
is necessary in order to call the mutation when a form submit -
jsonSchema
is necessary for extract mutation arguments as form fields -
theme
is optional (see "Theming")
TypeScript Tips
For TypeScript users, configure()
takes a "type arguments" for mutations names union types.
The script generates 3 files, including a mutations.d.ts
that expose a ApolloFormMutationNames
type.
Providing ApolloFormMutationNames
to configure()
will allow nice autocomplete when building a form (see next section)
import * as React from 'react';
import { configure } from 'react-apollo-form';
import { client } from './apollo'; // a file thats export a configured Apollo Client
const jsonSchema = require('./core/apollo-form-json-schema.json');
export const ApplicationForm = configure<ApolloFormMutationNames>({
// tslint:disable-next-line:no-any
client: client as any,
jsonSchema
});