Commit 0b6a5793 authored by Shane Thomas's avatar Shane Thomas
Browse files

Issue #3307224 by codekarate: Allow basic support for gatsby-source-graphql

parent f735f092
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@ incrementalbuild_url: ''
contentsync_url: ''
build_published: true
log_json: false
custom_source_plugin: ''
supported_entity_types: []
preview_target: ''
preview_callback_url: ''
publish_private_files: false
log_published: false
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ gatsby.settings:
    log_json:
      type: boolean
      label: 'Log JSON'
    custom_source_plugin:
      type: string
      label: 'Custom Source Plugin'
    supported_entity_types:
      type: sequence
      label: 'Supported entity types'
+10 −10
Original line number Diff line number Diff line
@@ -166,14 +166,6 @@ class GatsbyAdminForm extends ConfigFormBase {
      '#description' => $this->t('What entities should be sent to the Gatsby Preview and Build Server?'),
      '#weight' => 2,
    ];
    $form['preview']['preview_target'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Preview target'),
      '#description' => $this->t('With Gatsby v4 the Content Sync URL provides an alternative solution for previewing content changes. Do not include a trailing slash.'),
      '#default_value' => $config->get('preview_target'),
      '#maxlength' => 250,
      '#weight' => 3,
    ];

    $form['advanced'] = [
      '#type' => 'fieldset',
@@ -186,6 +178,14 @@ class GatsbyAdminForm extends ConfigFormBase {
      '#default_value' => $config->get('log_json'),
      '#weight' => 3,
    ];
    $form['advanced']['custom_source_plugin'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Gatsby Cloud: Custom source plugin'),
      '#description' => $this->t('On Gatsby Cloud this module only works with gatsby-source-drupal by default. If you are building a custom plugin or using gatsby-source-graphql (not recommended), you can enter the full source plugin name here (such as "gatsby-source-graphql"). This is experimental and not officially supported.'),
      '#default_value' => $config->get('custom_source_plugin'),
      '#maxlength' => 250,
      '#weight' => 4,
    ];

    $form['fastbuilds'] = [
      '#type' => 'fieldset',
@@ -302,9 +302,9 @@ class GatsbyAdminForm extends ConfigFormBase {
      ->set('contentsync_url', $form_state->getValue('contentsync_url'))
      ->set('build_published', $form_state->getValue('build_published'))
    ->set('supported_entity_types', array_values(array_filter($form_state->getValue('supported_entity_types'))))
      ->set('preview_target', $form_state->getValue('preview_target'))
      ->set('path_mapping', $form_state->getValue('path_mapping'))
      ->set('log_json', $form_state->getValue('log_json'))
    ->set('custom_source_plugin', $form_state->getValue('custom_source_plugin'))
      ->set('publish_private_files', $form_state->getValue('publish_private_files'))
      ->set('log_published', $form_state->getValue('log_published'))
      ->set('delete_log_entities', $form_state->getValue('delete_log_entities'))
+6 −0
Original line number Diff line number Diff line
@@ -253,6 +253,12 @@ class GatsbyPreview {
      }
    }

    // Add optional source plugin header for use on Gatsby Cloud with custom
    // source plugins.
    if (!empty($this->configFactory->get('gatsby.settings')->get('custom_source_plugin'))) {
      $arguments['headers']['x-gatsby-cloud-data-source'] = $this->configFactory->get('gatsby.settings')->get('custom_source_plugin');
    }

    // Trigger the HTTP request.
    try {
      $this->httpClient->post($preview_callback_url . $path, $arguments);