npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-source-gravityforms

v1.0.18

Published

Gatsby source plugin to add WordPress Gravity Forms nodes to your app.

Downloads

201

Readme

gatsby-source-gravityforms

This plugin connects to a WordPress Gravity Forms install. It finds all active forms and settings and adds them to the Gatsby nodes.

It uses 0Auth 1.0a Authentication for a higher level of security.

No Long Maintained. Outdated Package

I am no longer maintaining this package. A cleaner way of handling Gravity Forms is over at this repo: https://github.com/robmarshall/gatsby-plugin-gravity-forms

It handles both the sourcing, and rendering of a Gravity Form.

Installation

# Install the plugin
yarn add gatsby-source-gravityforms

# Or with NPM
npm i gatsby-source-gravityforms

Add to gatsby-config.js:

Default Setup

module.exports = {
    plugins: [
        {
            resolve: 'gatsby-source-gravityforms',
            options: {
                // Base URL needs to include protocol (http/https)
                baseUrl: 'SITE_BASE_URL',
                include: [], // Array of form IDs. Will only import these forms.
                exclude: [], // Array of form IDs. Will exclude these forms.
                // Gravity Forms API
                allowSelfSigned: false,
                api: {
                    key: 'CONSUMER_KEY',
                    secret: 'CONSUMER_SECRET',
                },
            },
        },
    ],
}

Remember to store secret keys/important data as environment variables and not in client side code.

All Options

module.exports = {
    plugins: [
        {
            resolve: 'gatsby-source-gravityforms',
            options: {
                // Base URL needs to include protocol (http/https)
                baseUrl: 'SITE_BASE_URL',
                // Gravity Forms API
                api: {
                    key: 'CONSUMER_KEY',
                    secret: 'CONSUMER_SECRET',
                },
                // Set to true to enable selfsigned certs in development mode
                allowSelfSigned: false,
                // Basic Auth
                basicAuth: {
                    username: 'USERNAME',
                    password: 'PASSWORD',
                },
                ignoreFields: [
                    // Top level fields within the Gravity Forms return
                    // to ignore.
                    // Default ignore is 'notifications'. To keep this
                    // as set, remove the ignoreFields setting from here.
                    // If adding more fields, you will need to include
                    // notifications to ensure it is ignored.
                ],
            },
        },
    ],
}

Gravity Forms REST API Settings

Step by step - How to connect

To use the Gravity Forms REST API, it needs to be enabled within the Gravity Forms Settings. This is found under "General Settings".

Once "Enable access to the API" has been checked, Gravity Forms will give you the ability to create API keys. These two keys (consumer & secret) are the keys required in the gatsby-config.js file as key & secret.

It is recommended to create one API key for use with this Source Plugin, set to Read access only. Then if Write access is required to submit the forms, create a separate one.

Basic Auth

Your backend API may be set up with Basic Auth in place. This is added to the beginning of the URL so 0auth1 can also run in tandem. Setup is shown above in Installation.

How To Query

A recommended data set can be extracted from GraphQL using the following query:

{
    allGfForm {
        edges {
            node {
                formId
                slug
                apiURL
                descriptionPlacement
                formFields {
                    id
                    label
                    labelPlacement
                    description
                    descriptionPlacement
                    type
                    choices
                    content //remove if not using HTML Content
                    errorMessage
                    inputMaskValue
                    isRequired
                    visibility
                    cssClass
                    placeholder
                    size
                    defaultValue
                    maxLength
                    conditionalLogic
                    emailConfirmEnabled
                    enableOtherChoice
                }
                button {
                    text
                }
                confirmations {
                    message
                }
            }
        }
    }
}

This will return each form set up in Gravity Forms. It will include:

  • Slug of the form title
  • The backend form REST API URL
  • All form fields
  • Button info
  • Confirmation info

Currently "choices" in formFields is stringified and will need to be parsed when extracted. This is due to Gatsby seemingly not seeing this many level deep.

Using the Data

The second step to all this is parsing the data, it needs to be displayed. With a few more steps outlined in the component below, Gravity Forms will be completely connected to your static site.

gatsby-gravityforms-component

It is still a WIP, but feel free to help develop it/use as it is.

Development / Testing

If you are interested in helping progress the plugin, please do! Although it works, there is still a lot to do.

Cache

when developing, remember to clear the cache as you work on the plugin. Gatsby is very effective in making building a site quickly, but it does not help when trying to work out issues. Clear the cache whenever you make a content/query change.