You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/tutorials/getting-started-with-graphql.md
+40-40Lines changed: 40 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,48 +132,10 @@ use AshGraphql, domains: [Your.Domain1, Your.Domain2]
132
132
133
133
Some example queries/mutations are shown below. If no queries/mutations are added, nothing will show up in the GraphQL API, so be sure to set one up if you want to try it out.
134
134
135
-
### Queries & Mutations on the Resource
136
-
137
-
Here we show queries and mutations being added to the resource, but you can also define them on the _domain_. See below for an equivalent definition
138
-
139
-
```elixir
140
-
defmodule Helpdesk.Support.Ticket do
141
-
use Ash.Resource,
142
-
...,
143
-
extensions: [
144
-
AshGraphql.Resource
145
-
]
146
-
147
-
graphql do
148
-
type :ticket
149
-
150
-
queries do
151
-
# Examples
152
-
153
-
# create a field called `get_ticket` that uses the `read` read action to fetch a single ticke
154
-
get :get_ticket, :read
155
-
# create a field called `most_important_ticket` that uses the `most_important` read action to fetch a single record
156
-
read_one :most_important_ticket, :most_important
157
-
158
-
# create a field called `list_tickets` that uses the `read` read action to fetch a list of tickets
159
-
list :list_tickets, :read
160
-
end
161
-
162
-
mutations do
163
-
# Examples
164
-
165
-
create :create_ticket, :create
166
-
update :update_ticket, :update
167
-
destroy :destroy_ticket, :destroy
168
-
end
169
-
end
170
-
171
-
...
172
-
end
173
-
```
174
-
175
135
### Queries & Mutations on the Domain
176
136
137
+
Here we show queries and mutations being added to the domain, but you can also define them on the resource. See below for an equivalent definition. Prefer to add to the domain so your interface is defined in one place.
138
+
177
139
```elixir
178
140
defmodule Helpdesk.Support.Ticket do
179
141
use Ash.Resource,
@@ -216,6 +178,44 @@ defmodule Helpdesk.Support do
216
178
end
217
179
```
218
180
181
+
### Queries & Mutations on the Resource
182
+
183
+
```elixir
184
+
defmodule Helpdesk.Support.Ticket do
185
+
use Ash.Resource,
186
+
...,
187
+
extensions: [
188
+
AshGraphql.Resource
189
+
]
190
+
191
+
graphql do
192
+
type :ticket
193
+
194
+
queries do
195
+
# Examples
196
+
197
+
# create a field called `get_ticket` that uses the `read` read action to fetch a single ticke
198
+
get :get_ticket, :read
199
+
# create a field called `most_important_ticket` that uses the `most_important` read action to fetch a single record
200
+
read_one :most_important_ticket, :most_important
201
+
202
+
# create a field called `list_tickets` that uses the `read` read action to fetch a list of tickets
0 commit comments