Skip to content

Commit d80b9a0

Browse files
committed
Fix merge 8.x.4.x
2 parents d19bf09 + 4f92c53 commit d80b9a0

36 files changed

+959
-56
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
run: composer --no-interaction --no-progress require \
8686
webonyx/graphql-php:^14.8 \
8787
drupal/typed_data:^1.0 \
88+
drupal/redirect:^1.0 \
8889
phpstan/phpstan:^1.7.14 \
8990
mglaman/phpstan-drupal:^1.1.2 \
9091
phpstan/phpstan-deprecation-rules:^1.0.0 \

assets/explorer/dist/bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/explorer/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Explorer from './Explorer';
1010
*/
1111
Drupal.behaviors.graphQLRenderExplorer = {
1212
attach: (context, settings) => {
13-
const container = jQuery('#graphql-explorer', context).once('graphql-explorer')[0] || undefined;
13+
const container = jQuery(once('graphql-explorer', '#graphql-explorer', context))[0] || undefined;
1414

1515
if (typeof container === 'undefined') {
1616
return;

assets/voyager/dist/bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/voyager/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"lint": "eslint src"
77
},
88
"dependencies": {
9+
"@drupal/once": "^1.0.1",
910
"graphql": "^15.5.1",
1011
"graphql-voyager": "^1.0.0-rc.27",
1112
"react": "^16.3",

assets/voyager/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import ReactDOM from 'react-dom';
33
import { Voyager } from 'graphql-voyager';
44
import Drupal from 'drupal';
55
import jQuery from 'jquery';
6+
import once from '@drupal/once';
67

78
/**
89
* Behavior for rendering the GraphQL Voyager interface.
910
*/
1011
Drupal.behaviors.graphQLRenderVoyager = {
1112
attach: (context, settings) => {
12-
const container = jQuery('#graphql-voyager', context).once('graphql-voyager')[0] || undefined;
13+
const container = jQuery(once('graphql-voyager', '#graphql-voyager', context))[0] || undefined;
1314

1415
if (typeof container === 'undefined') {
1516
return;

assets/voyager/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.6.tgz#d5e0706cf8c6acd8c6032f8d54070af261bbbb2f"
100100
integrity sha512-ws57AidsDvREKrZKYffXddNkyaF14iHNHm8VQnZH6t99E8gczjNN0GpvcGny0imC80yQ0tHz1xVUKk/KFQSUyA==
101101

102+
"@drupal/once@^1.0.1":
103+
version "1.0.1"
104+
resolved "https://registry.yarnpkg.com/@drupal/once/-/once-1.0.1.tgz#7c1ef480aec6d5fa4b5ae986afa5a607afc38482"
105+
integrity sha512-O8tQmNDBgSm3ADuFZ5OZlGxsrdsc+pEqd1NBoMpSzWwiOnWwC91tqDwnlX+mDh7sBJoJ+4vVwFh0NLUV4LPFvg==
106+
102107
"@eslint/eslintrc@^1.1.0":
103108
version "1.1.0"
104109
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.1.0.tgz#583d12dbec5d4f22f333f9669f7d0b7c7815b4d3"

doc/producers/custom.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Custom data producers allow you essentially hook into any data of Drupal, becaus
66

77
Lets look at a custom Data producer that loads the current user (similar to the 3.x version of currentUser query).
88

9-
The first step as seen before is to add our query to the schema :
9+
The first step as seen before is to add our query to the schema :
1010

11-
```
11+
```
1212
type Query {
1313
...
1414
currentUser: User
@@ -21,7 +21,7 @@ type User {
2121
}
2222
```
2323

24-
Now that we have this we need to make a resolver that actually loads this user, but for that first we need our own custom data producer "CurrentUser" :
24+
Now that we have this we need to make a resolver that actually loads this user, but for that first we need our own custom data producer "CurrentUser" :
2525

2626
```php
2727
<?php
@@ -99,7 +99,7 @@ class CurrentUser extends DataProducerPluginBase implements ContainerFactoryPlug
9999

100100
We are defining a custom data producer `current_user` that we can now use to resolve our query that we previously added to the schema. Notice that our data producer returns only the user id and not the actual user object. However we can combine it with an entity_load which is already made very efficient with in the module (taking advantage of caching strategies using buffering) so we don't have to actually load the user here.
101101

102-
Lets see how we can consume our newly created data producer :
102+
Lets see how we can consume our newly created data producer :
103103

104104
```php
105105
$registry->addFieldResolver('Query', 'currentUser', $builder->compose(
@@ -112,7 +112,7 @@ $registry->addFieldResolver('Query', 'currentUser', $builder->compose(
112112

113113
Notice how we combine our custom data producer with a built-in `entity_load` to make querying more performance and standardized across. We will look at `compose` in more detail in the next section.
114114

115-
In the end when we do a query like this :
115+
In the end when we do a query like this :
116116

117117
```graphql
118118
{
@@ -123,7 +123,7 @@ In the end when we do a query like this :
123123
}
124124
```
125125

126-
we get a result like this :
126+
we get a result like this :
127127

128128
```json
129129
{
@@ -136,4 +136,15 @@ we get a result like this :
136136
}
137137
```
138138

139-
(For this to actually work we would need to add resolvers to the User object to resolve the `id` and `name` properties).
139+
For this to actually work we would need to add resolvers to the User object to resolve the `id` and `name` properties like so:
140+
```php
141+
$registry->addFieldResolver('User', 'id', $builder->callback(function ($account) {
142+
/** @var \Drupal\Core\Session\AccountProxyInterface $account */
143+
return $account->id();
144+
}));
145+
146+
$registry->addFieldResolver('User', 'name', $builder->callback(function ($account) {
147+
/** @var \Drupal\Core\Session\AccountProxyInterface $account */
148+
return $account->getAccountName();
149+
}));
150+
```

graphql.libraries.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ explorer:
99
dependencies:
1010
- core/drupal
1111
- core/jquery
12-
- core/jquery.once
12+
- core/once
1313

1414
voyager:
1515
version: VERSION
@@ -23,7 +23,7 @@ voyager:
2323
dependencies:
2424
- core/drupal
2525
- core/jquery
26-
- core/jquery.once
26+
- core/once
2727

2828
persisted_queries:
2929
version: VERSION
@@ -32,4 +32,4 @@ persisted_queries:
3232
dependencies:
3333
- core/drupal
3434
- core/jquery
35-
- core/jquery.once
35+
- core/once

graphql.routing.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ graphql.explorer:
4848
options:
4949
_admin_route: TRUE
5050
parameters:
51-
server:
52-
type: entity:graphql_server
51+
graphql_server:
52+
with_config_overrides: TRUE
5353

5454
graphql.voyager:
5555
path: '/admin/config/graphql/servers/manage/{graphql_server}/voyager'
@@ -62,7 +62,7 @@ graphql.voyager:
6262
_admin_route: TRUE
6363
parameters:
6464
graphql_server:
65-
type: entity:graphql_server
65+
with_config_overrides: TRUE
6666

6767
graphql.validate:
6868
path: '/admin/config/graphql/servers/manage/{graphql_server}/validate'
@@ -75,8 +75,7 @@ graphql.validate:
7575
_admin_route: TRUE
7676
parameters:
7777
graphql_server:
78-
type: entity:graphql_server
79-
78+
with_config_overrides: TRUE
8079

8180
entity.graphql_server.delete_form:
8281
path: '/admin/config/graphql/servers/manage/{graphql_server}/delete'

0 commit comments

Comments
 (0)