Skip to content

Commit

Permalink
Invert the instructions for installing subscriptions with phoenix. (#…
Browse files Browse the repository at this point in the history
…1125)

* Invert the phoenix installation instructions.

Add the instructions for current versions of Phoenix as the default, and then explain how to use in older versions rather than the other way around.

* Restore fence syntax
  • Loading branch information
JonRowe authored Nov 25, 2021
1 parent 738f97b commit 1ac2654
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions guides/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,7 @@ In your application supervisor add a line _after_ your existing endpoint supervi
line:

```elixir
[
# other children ...
supervisor(MyAppWeb.Endpoint, []), # this line should already exist
supervisor(Absinthe.Subscription, MyAppWeb.Endpoint), # add this line
# other children ...
]
```

In Phoenix v1.4, the supervisor children are mounted like so:

```elixir
# List all child processes to be supervised
# List all child processes to be supervised
children = [
# Start the Ecto repository
MyAppWeb.Repo,
Expand All @@ -52,7 +41,19 @@ In Phoenix v1.4, the supervisor children are mounted like so:
# for other strategies and supported options
opts = [strategy: :one_for_one, name: MyAppWeb.Supervisor]
Supervisor.start_link(children, opts)
```

In older versions of phoenix (pre 1.4) you might see a slightly different syntax,
in which case add Absinthe like this:

```elixir
[
# other children ...
MyAppWeb.Repo,
supervisor(MyAppWeb.Endpoint, []), # this line should already exist
supervisor(Absinthe.Subscription, MyAppWeb.Endpoint), # add this line
# other children ...
]
```

Where `MyAppWeb.Endpoint` is the name of your application's phoenix endpoint.
Expand Down

0 comments on commit 1ac2654

Please sign in to comment.