Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: readme updated #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,75 @@ See <https://www.drupal.org/files/issues/2023-10-01/Configuring%20Drupal%20to%20

If you used the Sous Project as your starterkit:

- `lando install-recipe sous-graphql`
- `lando install-recipe fourkitchens/sous-graphql`

Manually applying the recipe to your own project: From your webroot run:

- `php core/scripts/drupal recipe recipes/sous-graphql`
- `drush cr`
- `composer unpack fourkitchens/sous-graphql`

## Drupal configuration

### Setting Up OAuth and Configuration
- Create an oauth folder in the private files directory: `web/sites/default/files/private/oauth`
- Go to `/admin/config/people/simple_oauth` click Generate keys, set the Directory for the keys to `/app/web/sites/default/files/private/oauth`, generate, and save the configuration.

## Setting Up hash_salt
- Run `lando drush php-eval 'echo \Drupal\Component\Utility\Crypt::randomBytesBase64(55)' | pbcopy`. [See more](https://blokspeed.net/2018/quick-tip-generating-hash-salt-drupal-8)
- Go to `web/sites/default/settings.php` and paste the output from the previous command into the hash_salt setting.
```
$settings['hash_salt'] = 'OUTPUT';
```

### Create Role for GraphQL API
- Create a role with these permissions (e.g., GraphQL API):
- GraphQL Compose - Server: Execute arbitrary requests
- View media
- View own unpublished media
- View user email addresses
- View user information

### Create User
- Create a user with the new role (e.g., username: `nextjs` and email `[email protected]`).

### Create Consumer
- Go to `/admin/config/services/consumer`
- Create or modify a consumer:
- Generate a Client ID and save it for later use in the Front-End config. (just by clicking `Generate random client ID` in the form)
- Assign the user you created.
- Set a New Secret (save for Front-End config).
- Uncheck `Is this consumer 3rd party`.
- Select the role created in Scopes field.
- Save.

### Configuring GraphQL Compose
- Pretending you have a content type called `page`
- Create a page node for testing.
- Go to `/admin/config/graphql_compose` and enable:
- GraphQL Loading by route
- Fields for content/media types as needed.

### Test GraphQL Queries
- Go to `/admin/config/graphql/servers/manage/graphql_compose_server/explorer`.
- Use the explorer helper (new folder icon in the left sidebar) to build queries, e.g.:
``` graphql
query MyQuery {
route(path: "/node/1") {
... on RouteInternal {
__typename
entity {
... on NodePage {
id
title
text {
value
}
}
}
}
}
}
```
- Click the execute button and verify results.
- Congratulations! You can now run GraphQL queries.