Created
December 5, 2019 08:00
-
-
Save SvenAlHamad/aaa3ad3fb34fc9513b24597ea9ee26ad to your computer and use it in GitHub Desktop.
Steps to add Webiny Form Builder to your Webiny CMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order to add the Form Builder app to an existing Webiny installation, simply add the following section into your `api/serverless.yml` file: | |
```yaml | |
formBuilder: | |
component: "@webiny/serverless-form-builder" | |
inputs: | |
name: "Form Builder" | |
region: ${vars.region} | |
files: ${files} | |
i18n: ${i18n} | |
memory: 512 | |
timeout: 30 | |
plugins: | |
- factory: "@webiny/api-plugin-create-apollo-handler" | |
options: ${vars.apollo} | |
- factory: "@webiny/api-plugin-commodo-mongodb" | |
options: ${vars.commodo} | |
- factory: "@webiny/api-security/plugins/service" | |
options: ${vars.security} | |
- "@webiny/api-plugin-form-builder-resolvers-mongodb" | |
``` | |
Now scroll over to the `gateway` component in the same `serverless.yml` file (usually located on top of the file), and add the following snippet into the `services` option of the `@webiny/api-plugin-create-apollo-gateway` plugin: | |
```yaml | |
- name: formBuilder | |
url: ${formBuilder.api.graphqlUrl} | |
``` | |
This will register your newly deployed Form Builder GraphQL service in the Apollo Gateway. | |
Note: In order for this to work correctly, the packages listed above must be installed: | |
- `@webiny/serverless-form-builder` | |
- `@webiny/api-plugin-create-apollo-handler` | |
- `@webiny/api-plugin-commodo-mongodb` | |
- `@webiny/api-security/plugins/service` | |
- `@webiny/api-plugin-form-builder-resolvers-mongodb` | |
Once you're done, the API can be deployed using `webiny deploy-api --debug` (added `--debug` flag just for additional logging). | |
Now that you have the API deployed, you need to add the form-builder plugins into your `admin` and `site` apps. | |
1. Open `apps/site/src/plugins/index.js`, and import the following: | |
``` | |
import formBuilderSitePlugins from "@webiny/app-forms/site/plugins"; | |
import formBuilderPbPlugins from "@webiny/app-forms/page-builder/site/plugins"; | |
``` | |
Then append these to the `plugins` array, like so: | |
``` | |
const plugins = [ | |
(...) | |
formBuilderSitePlugins, | |
formBuilderPbPlugins | |
]; | |
``` | |
2. Open `apps/admin/src/plugins/index.js`, and import the following: | |
``` | |
import formBuilderPlugins from "@webiny/app-forms/admin/plugins"; | |
import formBuilderPageBuilderPlugins from "@webiny/app-forms/page-builder/admin/plugins"; | |
``` | |
Then append these to the `plugins` array, like so: | |
``` | |
const plugins = [ | |
(...) | |
formBuilderPlugins, | |
formBuilderPageBuilderPlugins, | |
]; | |
``` | |
Note: you must have `@webiny/app-forms` package installed in order for this to work properly. | |
Now, either start local development by running `yarn start` in the `admin` or `site` folders, or deploy the apps using the `webiny deploy-apps --env dev --debug` (added `--debug` flag just for additional logging). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment