Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Jun 21, 2024
1 parent db78d3b commit 06fb118
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .lagoon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,16 @@ environments:
schedule: '*/15 * * * *'
command: drush cron
service: cli
lagoon-waku:
routes:
- nginx:
- waku.cms.amazeelabs.dev
- build:
- waku.build.amazeelabs.dev
- preview:
- waku.preview.amazeelabs.dev
cronjobs:
- name: drush cron
schedule: '*/15 * * * *'
command: drush cron
service: cli
7 changes: 7 additions & 0 deletions apps/cms/.lagoon.env.lagoon-waku
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PROJECT_NAME=example
PUBLISHER_URL="https://waku.build.amazeelabs.dev"
NETLIFY_URL="https://waku.amazeelabs.dev"
PREVIEW_URL="https://waku.preview.amazeelabs.dev"

# Used to set the original client secret.
PUBLISHER_OAUTH2_CLIENT_SECRET=REPLACE_ME
1 change: 1 addition & 0 deletions apps/preview/.lagoon.env.lagoon-waku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DRUPAL_URL="https://waku.cms.amazeelabs.dev"
29 changes: 29 additions & 0 deletions apps/website/.lagoon.env.lagoon-waku
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
PROJECT_NAME=waku
DRUPAL_INTERNAL_URL="http://nginx:8080"
DRUPAL_EXTERNAL_URL="https://waku.cms.amazeelabs.dev"
NETLIFY_URL="https://waku.amazeelabs.dev"
NETLIFY_SITE_ID="ca4ea730-4703-4a61-b041-0a2a6983ee1d"

# -----------------------------------------------
# Publisher authentication with Drupal (OAuth2).
# See main ./README.md for more information.
# -----------------------------------------------
# Set to true to fully skip authentication.
PUBLISHER_SKIP_AUTHENTICATION=false

# Secret from the Drupal Publisher Consumer.
PUBLISHER_OAUTH2_CLIENT_SECRET=REPLACE_ME

# Client id from the Drupal Publisher Consumer.
PUBLISHER_OAUTH2_CLIENT_ID=publisher

# A random string, used to encrypt the session.
PUBLISHER_OAUTH2_SESSION_SECRET=REPLACE_ME

# "development" or "production", production will trust first proxy
# and serve secure cookies.
PUBLISHER_OAUTH2_ENVIRONMENT_TYPE=production

# DRUPAL_EXTERNAL_URL is used by default, but can be overridden
# to match the Drupal production url, without the nginx prefix.
PUBLISHER_OAUTH2_TOKEN_HOST="${DRUPAL_EXTERNAL_URL}"
9 changes: 5 additions & 4 deletions apps/website/src/drupal-executor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ function drupalExecutor(endpoint: string, forward: boolean = true) {
};
}

export function DrupalExecutor({ children }: PropsWithChildren) {
export function DrupalExecutor({
children,
url,
}: PropsWithChildren<{ url: string }>) {
return (
<OperationExecutorsProvider
executors={[
{ executor: drupalExecutor('http://localhost:8888/graphql', false) },
]}
executors={[{ executor: drupalExecutor(`${url}/graphql`, false) }]}
>
{children}
</OperationExecutorsProvider>
Expand Down
4 changes: 3 additions & 1 deletion apps/website/src/entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async function query<TOperation extends AnyOperationId>(
operation: TOperation,
variables: OperationVariables<TOperation>,
) {
const url = new URL('http://localhost:8888/graphql');
const url = new URL(
`${process.env.DRUPAL_INTERNAL_URL || 'http://localhost:8888'}/graphql`,
);
url.searchParams.set('queryId', operation);
url.searchParams.set('variables', JSON.stringify(variables || {}));
const { data, errors } = await (await fetch(url)).json();
Expand Down
8 changes: 7 additions & 1 deletion apps/website/src/executors-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ import React, { PropsWithChildren } from 'react';
import { DrupalExecutor } from './drupal-executor.js';

export function ExecutorsClient({ children }: PropsWithChildren) {
return <DrupalExecutor>{children}</DrupalExecutor>;
return (
<DrupalExecutor
url={process.env.DRUPAL_EXTERNAL_URL || 'http://localhost:8888'}
>
{children}
</DrupalExecutor>
);
}
8 changes: 7 additions & 1 deletion apps/website/src/executors-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ import React, { PropsWithChildren } from 'react';
import { DrupalExecutor } from './drupal-executor.js';

export function ExecutorsServer({ children }: PropsWithChildren) {
return <DrupalExecutor>{children}</DrupalExecutor>;
return (
<DrupalExecutor
url={process.env.DRUPAL_INTERNAL_URL || 'http://localhost:8888'}
>
{children}
</DrupalExecutor>
);
}

0 comments on commit 06fb118

Please sign in to comment.