Charly POLY - Senior Software Engineer at
React Europe 2019 speaker 🎙
Plateforme de marketplace freelance avec outil de gestion de projets intégré
Formulaires = travail manuel
Formulaires = API (champs + validations)Â + design/UX
Design system
UI-kit (components)
Formulaires = UI-kit + schéma de données
class Form extends ModuleForm {
fields: FieldsDefinitions = {
id: 'none',
email: 'none',
picture_path: {
type: 'image', transformations: 'h_200,w_200,r_max,c_fill'
},
first_name: 'string*',
last_name: 'string*',
username: 'string*',
job_title: 'string',
company_name: 'string',
language: {
type: 'select*',
component: LanguageSelectView,
valueProperty: 'code',
values: supportedLanguages,
moduleName: 'attachment'
}
};
constructor() {
super('UserForm', 'user');
}
}
Limitations
HTTP requests
SPA
GraphQL API
GraphQL Schema
Data types
Queries
Mutations
GraphQL API
mutation(user: UserInputType!, company: CompanyInputType) {
create_account(user: $user, company: $company) {
user {
id
}
}
}
mutation
Onboarding
Form
GraphQL API
User model
Company model
introspection
query
GraphQL API
{
"name": "createAccount",
"__typename": "__Field",
"isDeprecated": false,
"deprecationReason": null,
"args": [
{
"name": "user",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "InputType",
"name": "UserInputType",
"ofType": null,
"__typename": "__Type"
},
"__typename": "__Type"
},
"defaultValue": null,
"__typename": "__InputValue"
},
// ...
}
introspection
query
GraphQL API
You can create an Account by providing
a mandatory User type and
an optional Company type
Formulaires = API (champs + validations)Â + design/UX
design/UX = UI-kit
API (champs + validations) = GraphQL
const mutation = gql`
mutation ($company: String!, $email: String!, $firstname: String!, $lastname: String!) {
createUser(company: $company, $email: $email, $firstname: $firstname, $lastname: $lastname) {
id
}
}
`;
<Frontier client={client} mutation={mutation} uiKit={ApplicationUIkit}>
{
({ form, kit }) => {
return (
<form className='ui form' onSubmit={(e) => { e.preventDefault(); form.submit(); }}>
<div>
{kit.company()}
</div>
<Message
info
header='Is my company already registered?'
list={[
'If your company is already registred under a Business plan, please do register using the Business form',
]}
/>
<br />
<br />
<div>
{kit.email()}
</div>
<br />
<div>
{kit.firstname()}
</div>
<br />
<div>
{kit.lastname()}
</div>
<p>
<input type="submit" value="Save" className="ui button" />
</p>
</form>
)
}
}
</Frontier>
GraphQL
final-form
Apollo GraphQL
Fields definitions
Form state
Save data
const mutation = gql`
mutation ($user: UserInputType!) {
createUser(user: $user) {
...User
}
}
`;
<Frontier mutation={mutation} client={client} uiKit={ApplicationUIkit} />
How to:
    We are hiring!
🔗  honest.engineering
    @whereischarly
    /wittydeveloper
Questions ?