Skip to content

Commit a69b27a

Browse files
authored
Improve README (#190)
1 parent adf4e74 commit a69b27a

1 file changed

Lines changed: 24 additions & 25 deletions

File tree

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,25 @@ GraphQL interface on top of the [Devise Token Auth](https://github.com/lynndylan
1414
* [Installation](#installation)
1515
* [Running the Generator](#running-the-generator)
1616
* [Mounting the Schema in a Separate Route](#mounting-the-schema-in-a-separate-route)
17-
* [Important](#important)
18-
* [Mounting Operations in Your Own Schema (> v0.12.0)](#mounting-operations-in-your-own-schema--v0120)
19-
* [Important](#important-1)
17+
* [Mounting Operations in an Existing Schema (> v0.12.0)](#mounting-operations-in-an-existing-schema--v0120)
2018
* [Usage](#usage)
2119
* [Mounting Auth Schema on a Separate Route](#mounting-auth-schema-on-a-separate-route)
22-
* [Mounting Operations Into Your Own Schema](#mounting-operations-into-your-own-schema)
20+
* [Mounting Operations In an Existing Schema](#mounting-operations-in-an-existing-schema)
2321
* [Available Mount Options](#available-mount-options)
2422
* [Available Operations](#available-operations)
2523
* [Configuring Model](#configuring-model)
2624
* [Email Reconfirmation](#email-reconfirmation)
25+
* [Current flow](#current-flow)
2726
* [Deprecated flow - Do Not Use](#deprecated-flow---do-not-use)
2827
* [Customizing Email Templates](#customizing-email-templates)
2928
* [I18n](#i18n)
3029
* [Authenticating Controller Actions](#authenticating-controller-actions)
3130
* [Authenticate Resource in the Controller (>= v0.15.0)](#authenticate-resource-in-the-controller--v0150)
3231
* [Authentication Options](#authentication-options)
3332
* [Authenticate Before Reaching Your GQL Schema (Deprecated)](#authenticate-before-reaching-your-gql-schema-deprecated)
34-
* [Authenticate in Your GQL Schema (Deprecated)](#authenticate-in-your-gql-schema-deprecated)
33+
* [Authenticate in an Existing Schema (Deprecated)](#authenticate-in-an-existing-schema-deprecated)
3534
* [Authentication Options](#authentication-options-1)
36-
* [Important](#important-2)
35+
* [Important](#important)
3736
* [Making Requests](#making-requests)
3837
* [Introspection query](#introspection-query)
3938
* [Mutations](#mutations)
@@ -48,7 +47,7 @@ GraphQL interface on top of the [Devise Token Auth](https://github.com/lynndylan
4847
* [Contributing](#contributing)
4948
* [License](#license)
5049

51-
<!-- Added by: mcelicalderon, at: Tue Jun 8 22:47:12 -05 2021 -->
50+
<!-- Added by: david, at: jue jun 24 18:32:27 -05 2021 -->
5251

5352
<!--te-->
5453

@@ -82,11 +81,10 @@ Graphql Devise generator will execute `Devise` and `Devise Token Auth` generator
8281
```bash
8382
$ bundle exec rails generate graphql_devise:install
8483
```
85-
The generator accepts 2 params:
84+
The generator accepts 2 params and 1 option:
8685
- `user_class`: Model name in which `Devise` modules will be included. This uses a `find or create` strategy. Defaults to `User`.
8786
- `mount_path`: Path in which the dedicated graphql schema for devise will be mounted. Defaults to `/graphql_auth`.
88-
89-
The option `mount` is available starting from `v0.12.0`. This option will allow you to mount the operations in your own schema instead of a dedicated one. When this option is provided `mount_path` param is not used.
87+
- `--mount`: This options is available starting from `v0.12.0`, it allows you to mount the operations in your own schema instead of a dedicated one. When provided `mount_path` param is ignored.
9088

9189
#### Mounting the Schema in a Separate Route
9290

@@ -109,12 +107,12 @@ Will do the following:
109107
`Admin` could be any model name you are going to be using for authentication,
110108
and `api/auth` could be any mount path you would like to use for auth.
111109

112-
##### Important
110+
**Important**
113111
- Remember that by default this gem mounts a completely separate GraphQL schema on a separate controller in the route provided by the `at` option in the `mount_graphql_devise_for` method in the `config/routes.rb` file. If no `at` option is provided, the route will be `/graphql_auth`.
114-
- Avoid passing the `--mount` option or the gem will try to use an existing schema.
112+
- Avoid passing the `--mount` option if you want to use a separate route and schema.
115113

116-
#### Mounting Operations in Your Own Schema (> v0.12.0)
117-
To configure the gem to use your own GQL schema use the `--mount` option.
114+
#### Mounting Operations in an Existing Schema (> v0.12.0)
115+
To configure the gem to use an existing GQL schema use the `--mount` option.
118116
For instance the executing:
119117

120118
```bash
@@ -130,8 +128,8 @@ Will do the following:
130128
- Add `SchemaPlugin` to the specified schema.
131129

132130

133-
##### Important
134-
- When using the `--mount` option the `mount_path` params is ignored.
131+
**Important**
132+
- When using the `--mount` option the `mount_path` param is ignored.
135133
- The generator will look for your schema under `app/graphql/` directory. We are expecting the name of the file is the same as the as the one passed in the mount option transformed with `underscore`. In the example, passing `MySchema`, will try to find the file `app/graphql/my_schema.rb`.
136134
- You can actually mount a resource's auth schema in a separate route and in your app's schema at the same time, but that's probably not a common scenario.
137135

@@ -176,10 +174,10 @@ The second argument of the `mount_graphql_devise` method is a hash of options wh
176174
customize how the queries and mutations are mounted into the schema. For a list of available
177175
options go [here](#available-mount-options)
178176

179-
### Mounting Operations Into Your Own Schema
177+
### Mounting Operations In an Existing Schema
180178

181-
Starting with `v0.12.0` you can now mount the GQL operations provided by this gem into your
182-
app's main schema.
179+
Starting with `v0.12.0` you can mount the GQL operations provided by this gem into an
180+
existing schema in you app.
183181

184182
```ruby
185183
# app/graphql/dummy_schema.rb
@@ -353,10 +351,11 @@ to call a different update method on your resource,`update_with_email`.
353351
When the resource is not reconfirmable or the email is not updated, this method behaves exactly
354352
the same as ActiveRecord's `update`.
355353

354+
#### Current flow
356355
`update_with_email` requires one additional attribute when email will change or an error
357356
will be raised:
358357

359-
1. `confirmation_url`: The full url of your client application. The confirmation email will contain this url plus
358+
- `confirmation_url`: The full url of your client application. The confirmation email will contain this url plus
360359
a confirmation token. You need to call `confirmRegistrationWithToken` with the given token on
361360
your client application.
362361

@@ -374,12 +373,12 @@ user.update_with_email(
374373
`update_with_email` requires two additional attributes when email will change or an error
375374
will be raised:
376375

377-
1. `schema_url`: The full url where your GQL schema is mounted. You can get this value from the
376+
- `schema_url`: The full url where your GQL schema is mounted. You can get this value from the
378377
controller available in the context of your mutations and queries like this:
379378
```ruby
380379
context[:controller].full_url_without_params
381380
```
382-
1. `confirmation_success_url`: This the full url where you want users to be redirected after
381+
- `confirmation_success_url`: This the full url where you want users to be redirected after
383382
the email has changed successfully (usually a front-end url). This value is mandatory
384383
unless you have set `default_confirm_success_url` in your devise_token_auth initializer.
385384

@@ -459,7 +458,7 @@ schema. Configure the plugin as explained [here](#mounting-operations-into-your-
459458
so this can work.
460459

461460
##### Authentication Options
462-
Wether you setup authentications as a default in the plugin, or you do it at the field level,
461+
Whether you setup authentications as a default in the plugin, or you do it at the field level,
463462
these are the options you can use:
464463
1. **Any truthy value:** If `current_resource` is not `.present?`, query will return an authentication error.
465464
1. **A callable object:** Provided object will be called with `current_resource` as the only argument if `current_resource` is `.present?`. If return value of the callable object is false, query will return an authentication error.
@@ -501,7 +500,7 @@ end
501500
The install generator can include the concern in you application controller.
502501
If authentication fails for a request, execution will halt and a REST error will be returned since the request never reaches your GQL schema.
503502

504-
#### Authenticate in Your GQL Schema (Deprecated)
503+
#### Authenticate in an Existing Schema (Deprecated)
505504
For this you will need to add the `GraphqlDevise::SchemaPlugin` to your schema as described
506505
[here](#mounting-operations-into-your-own-schema).
507506

@@ -537,7 +536,7 @@ schema. Configure the plugin as explained [here](#mounting-operations-into-your-
537536
so this can work.
538537

539538
##### Authentication Options
540-
Wether you setup authentications as a default in the plugin, or you do it at the field level,
539+
Whether you setup authentications as a default in the plugin, or you do it at the field level,
541540
these are the options you can use:
542541
1. **Any truthy value:** If `current_resource` is not `.present?`, query will return an authentication error.
543542
1. **A callable object:** Provided object will be called with `current_resource` as the only argument if `current_resource` is `.present?`. If return value of the callable object is false, query will return an authentication error.

0 commit comments

Comments
 (0)