Skip to content

Commit

Permalink
style(cspell): Fix misspelled words (#1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
klausi committed Aug 3, 2024
1 parent b677475 commit b37fd9e
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .cspell-project-words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dataproducer
dataproducers
GraphiQL
graphqls
webonyx
6 changes: 3 additions & 3 deletions doc/mutations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ input ArticleInput {
}
```

And now in our `.exntends.graphqls` file we will extend the Mutation type to add our new mutation. This is so that in the future other modules can also themselves extend this type with new mutations keeping things organized.
And now in our `.extends.graphqls` file we will extend the Mutation type to add our new mutation. This is so that in the future other modules can also themselves extend this type with new mutations keeping things organized.

```
extend type Mutation {
Expand Down Expand Up @@ -137,10 +137,10 @@ class CreateArticle extends DataProducerPluginBase implements ContainerFactoryPl
}
```

### Important note
### Important note

One thing to notice when creating mutations like this is that Access checking needs to be done in the mutation, for queries this usually is done in the
data producer directly (e.g. `entity_load` has access checking built-in) but because we are programatically creating
data producer directly (e.g. `entity_load` has access checking built-in) but because we are programmatically creating
things we need to check the user actually has access to do the operation.

## Calling the mutation
Expand Down
6 changes: 3 additions & 3 deletions doc/mutations/validations.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ We define a Violation scalar which will just hold the error messages that will b

## Create the ArticleResponse class

Because we need adition content inside our Response we make a class that implements the module's ResponseInterface. Inside it will have a `article` property (like we saw before). This will be added in the `src/Wrappers/Response` folder and we will call it `ArticleResponse.php`
Because we need additional content inside our Response we make a class that implements the module's ResponseInterface. Inside it will have a `article` property (like we saw before). This will be added in the `src/Wrappers/Response` folder and we will call it `ArticleResponse.php`

```php

Expand Down Expand Up @@ -207,7 +207,7 @@ We have added a new type that is returned `$response` where we call the `setArti

## Resolve errors and article

To resolve our fields similar to before we go to our schema implementation again and add the resolvers for the
To resolve our fields similar to before we go to our schema implementation again and add the resolvers for the
`ArticleResponse` we created (what the mutation now returns back):

```php
Expand All @@ -232,7 +232,7 @@ public function registerResolvers(ResolverRegistryInterface $registry) {
}
```

And that's it if we now call this mutation for example as an anonymous user (if we set aribtrary queries enabled in the permissions for the module) we should get an error :
And that's it if we now call this mutation for example as an anonymous user (if we set arbitrary queries enabled in the permissions for the module) we should get an error :

```json
{
Expand Down
14 changes: 7 additions & 7 deletions doc/producers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ The 4.x version of the Drupal GraphQL module is built on top of a concept called

A data producer is more or less a function that takes arguments (either from an end user query or static) and resolves these into some other data, for example taking an entity (such as a node) and giving back a particular field.

Lets imagine we want to make a custom field available for a schema, in this case we have an `author` field in the "Article" content type. For this field we can have a producer that takes an entity and returns or resolves the creator field. Let's apply this to our custom schema which alreay defines an "Article" type.
Lets imagine we want to make a custom field available for a schema, in this case we have an `author` field in the "Article" content type. For this field we can have a producer that takes an entity and returns or resolves the creator field. Let's apply this to our custom schema which already defines an "Article" type.

## Add the field to the schema

In your `.graphqls` file add the schema defintion
In your `.graphqls` file add the schema definition

```
type Article {
Expand Down Expand Up @@ -44,7 +44,7 @@ $registry->addFieldResolver('Article', 'author',
)
);
```
Now you can make a sample article (as a user) and if you now go over to your graphql explorer and run the following query :
Now you can make a sample article (as a user) and if you now go over to your graphql explorer and run the following query :

```
{
Expand All @@ -54,9 +54,9 @@ Now you can make a sample article (as a user) and if you now go over to your gra
author
}
}
```
```

You should get a response in the same format e.g. :
You should get a response in the same format e.g. :

```json
{
Expand All @@ -68,11 +68,11 @@ You should get a response in the same format e.g. :
}
}
}
```
```

### Resolver builder

You need to initalize the `ResolverBuilder` once inside the `registerResolvers` method (or `getResolverRegistry` if you do not want to use schema extensions) in order to start registering resolvers. This is what will give you access to all the data producers by calling the `produce` method which takes as a parameter the data producer id.
You need to initialize the `ResolverBuilder` once inside the `registerResolvers` method (or `getResolverRegistry` if you do not want to use schema extensions) in order to start registering resolvers. This is what will give you access to all the data producers by calling the `produce` method which takes as a parameter the data producer id.

Essentially calling the `produce` method with the data producer id is what you need to do every time you want to make a field available in the schema. We tell Drupal where and how to get the data and specify where this maps to.

Expand Down
2 changes: 1 addition & 1 deletion doc/producers/composing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $registry->addFieldResolver('Query', 'currentUser', $builder->compose(
->map('type', $builder->fromValue('user'))
->map('id', $builder->fromParent()),
$builder->callback(function ($entity) {
// Here we can do anything we want to the data. We get as a parameter anyting that was returned
// Here we can do anything we want to the data. We get as a parameter anything that was returned
// in the previous step.
})
));
Expand Down
2 changes: 1 addition & 1 deletion doc/producers/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Now that we have this we need to make a resolver that actually loads this user,
```php
<?php

namespace Drupal\mydrupalgql\Plugin\GraphQL\DataProducer;
namespace Drupal\example\Plugin\GraphQL\DataProducer;

use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
Expand Down
6 changes: 3 additions & 3 deletions doc/starting/custom-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ This is the main entry point for your schema. You can insert new types, inputs a

For now all you need to know about this file is that it extends the base file. What this will allow is to better organize resolvers into different modules where each module might expose different things to the schema. The only existing type by default is `Query` and so to define new queries you have to add them here in the extension.graphqls file.

For more information about composable schemas go to [Advanced section](./../advanced/composable-schemas.md) when talking about spliting schemas so that you can make certain modules enable new functionalities as they are enabled.
For more information about composable schemas go to [Advanced section](./../advanced/composable-schemas.md) when talking about splitting schemas so that you can make certain modules enable new functionalities as they are enabled.

### Plugins

The module also includes some Plugins which are required inside the folder `src/Plugin/GraphQL/Schema` and optionally `src/Plugin/GraphQL/SchemaExtension`:

- ComposableSchemaExample.php : This file will define the schema itself. You can register default resolvers and also regular resolvers here. If you don't have a particular need you don't really need anything more than the anotation for your schema at first. Later with more complex examples we will show how it can be useful to add some base functionality (automatic resolvers or default resolvers).
- ComposableGraphQLSchemaExtension.php : This file will be used to implement resolvers in a way that is composeable (recommended). We recommend having at least one of these, but you can also implement resolvers across multiple modules by including several schema extensions in each module that exposes certain functionality to the schema when enabled. See the [Advanced section](./../advanced/composable-schemas.md) when talking about spliting schemas.
- ComposableSchemaExample.php : This file will define the schema itself. You can register default resolvers and also regular resolvers here. If you don't have a particular need you don't really need anything more than the annotation for your schema at first. Later with more complex examples we will show how it can be useful to add some base functionality (automatic resolvers or default resolvers).
- ComposableGraphQLSchemaExtension.php : This file will be used to implement resolvers in a way that is composable (recommended). We recommend having at least one of these, but you can also implement resolvers across multiple modules by including several schema extensions in each module that exposes certain functionality to the schema when enabled. See the [Advanced section](./../advanced/composable-schemas.md) when talking about splitting schemas.

#### Note

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/VoyagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Controller for the GraphQL Voyager visualisation API.
* Controller for the GraphQL Voyager visualization API.
*
* @codeCoverageIgnore
*/
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Execution/ExecutionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use GraphQL\Executor\ExecutionResult as LibraryExecutionResult;

/**
* Expand the upstream ExecutionResult to make it Drupal cachable.
* Expand the upstream ExecutionResult to make it Drupal cacheable.
*/
class ExecutionResult extends LibraryExecutionResult implements CacheableDependencyInterface {
use RefinableCacheableDependencyTrait;
Expand Down
8 changes: 4 additions & 4 deletions src/GraphQL/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public function getMissingResolvers(ServerInterface $server, array $ignore_types

if (!method_exists($resolver_registry, "getFieldResolverWithInheritance")) {
$this->logger->warning(
"Could not get missing resolvers for @server_name as its registry class (@klass) does not implement getFieldResolverWithInheritance.",
"Could not get missing resolvers for @server_name as its registry class (@class) does not implement getFieldResolverWithInheritance.",
[
'@server_name' => $server->id(),
'@klass' => get_class($resolver_registry),
'@class' => get_class($resolver_registry),
]
);
return [];
Expand Down Expand Up @@ -130,10 +130,10 @@ public function getOrphanedResolvers(ServerInterface $server, array $ignore_type

if (!method_exists($resolver_registry, "getAllFieldResolvers")) {
$this->logger->warning(
"Could not get orphaned resolvers for @server_name as its registry class (@klass) does not implement getAllFieldResolvers.",
"Could not get orphaned resolvers for @server_name as its registry class (@class) does not implement getAllFieldResolvers.",
[
'@server_name' => $server->id(),
'@klass' => get_class($resolver_registry),
'@class' => get_class($resolver_registry),
]
);
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/DataProducerPluginCachingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\graphql\Plugin;

/**
* Defines cachable data producer plugins.
* Defines a cacheable data producer plugins.
*/
interface DataProducerPluginCachingInterface extends DataProducerPluginInterface {

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/GraphQL/DataProducer/String/Uppercase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* name = @Translation("Uppercase"),
* description = @Translation("Transforms a string to uppercase."),
* produces = @ContextDefinition("string",
* label = @Translation("Uppercased string")
* label = @Translation("Uppercase converted string")
* ),
* consumes = {
* "string" = @ContextDefinition("string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function __construct(
* Resolves the taxonomy tree for given vocabulary.
*
* @param string $vid
* The vocanulary ID.
* The vocabulary ID.
* @param int $parent
* The ID of the parent's term to load the tree for.
* @param int|null $max_depth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: module
name: GraphQL Alterable Schema Test
description: Tests if alterting schema is working.
description: Tests if altering the schema is working.
package: Testing
hidden: TRUE
2 changes: 1 addition & 1 deletion tests/src/Kernel/DataProducer/EntityReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function setUp(): void {
]);
$content_type2->save();

$this->createEntityReferenceField('node', 'test1', 'field_test1_to_test2', 'test1 lable', 'node', 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->createEntityReferenceField('node', 'test1', 'field_test1_to_test2', 'test1 label', 'node', 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);

$this->referencedNode = Node::create([
'title' => 'Dolor2',
Expand Down
1 change: 1 addition & 0 deletions tests/src/Kernel/DataProducer/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function setUp(): void {
]);
$content_type->save();

// cspell:ignore otherbundle
$content_type = NodeType::create([
'type' => 'otherbundle',
'name' => 'otherbundle',
Expand Down
1 change: 1 addition & 0 deletions tests/src/Kernel/DataProducer/RoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function testUrlPath(): void {
*/
public function testUrlNotFound(): void {
$result = $this->executeDataProducer('route_load', [
// cspell:ignore idontexist
'path' => '/idontexist',
]);

Expand Down
1 change: 1 addition & 0 deletions tests/src/Kernel/Framework/PersistedQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function setUp(): void {
$this->mockResolver('Query', 'field_two', 'this is the field two');
$this->mockResolver('Query', 'field_three', []);
$this->mockResolver('Link', 'url', 'https://www.ecosia.org');
// cspell:ignore Ecosia
$this->mockResolver('Link', 'title', 'Ecosia');
}

Expand Down
1 change: 1 addition & 0 deletions tests/src/Kernel/Framework/TestFrameworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function testFieldMock(): void {
* Test result error assertions.
*/
public function testErrorAssertion(): void {
// cspell:ignore wrongname
$schema = <<<GQL
type Query {
wrongname: String
Expand Down
1 change: 1 addition & 0 deletions tests/src/Kernel/ResolverRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ResolverRegistryTest extends GraphQLTestBase {
public function setUp(): void {
parent::setUp();

// cspell:ignore Cabrio cabrio
$schema = <<<GQL
type Query {
transportation: Vehicle
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Traits/QueryResultAssertionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function assertResultData(ExecutionResult $result, $expected): void {
* @internal
*/
private function assertResultErrors(ExecutionResult $result, array $expected): void {
// Initalize the status.
// Initialize the status.
$unexpected = [];
$matchCount = array_fill_keys($expected, 0);

Expand Down

0 comments on commit b37fd9e

Please sign in to comment.