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
Appwrite provides two APIs to manager user accounts.
4
+
5
+
The Account API is the API you should use in your **client applications** like web, Flutter, mobile, and native apps.
6
+
Account API creates sessions, which represent an authenticated user and is attached to a user's [account](/docs/products/auth/account).
7
+
Sessions respect [permissions](/docs/advanced/platform/permissions), which means users can only access resources if they have been granted the correct permissions.
8
+
9
+
You'll notice that the Account API doesn't allow you to view or make changes to other users.
10
+
This is by design and for **security reasons**.
11
+
12
+
[Account API references](/docs/references/cloud/client-web/account)
13
+
14
+
The Users API is a dedicated API for managing users from an admin's perspective. **Do not use the Users API on client applications**.
15
+
It should be used with backend or server-side applications with the [Server SDK](#).
16
+
17
+
Users API uses API keys instead of sessions.
18
+
This means they're not resticted by permissions, but by the scopes granted to the API key used.
19
+
20
+
[Users API references](/docs/references/cloud/server-nodejs/users)
Copy file name to clipboardExpand all lines: src/routes/docs/advanced/platform/webhooks/+page.markdoc
-11Lines changed: 0 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,6 @@ title: Webhooks
4
4
description: Placeholder SEO.
5
5
---
6
6
7
-
Certainly! Below is the content converted to Markdown format:
8
-
9
-
```md
10
-
```php
11
-
<?php
12
-
13
-
$events = $this->getParam('events', []);
14
-
15
-
?>
16
-
```
17
-
18
7
Webhooks allow you to build or set up integrations which subscribe to certain events on Appwrite. When one of those events is triggered, we'll send an HTTP POST payload to the webhook's configured URL. Webhooks can be used to purge cache from CDN, calculate data or send a Slack notification. You're only limited by your imagination.
Copy file name to clipboardExpand all lines: src/routes/docs/advanced/self-hosting/functions/+page.markdoc
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -79,8 +79,6 @@ Check the **Any account** box under **Where can this GitHub App be installed?**
79
79
80
80
After creating your app, you'll have to configure the following environment variables.
81
81
82
-
Markdown doesn't natively support tables with complex markup like HTML does. However, you can create simple tables with Markdown. Here's a basic conversion of your table to Markdown:
| `_APP_DOMAIN` | Your main Appwrite domain used to access the Appwrite Console. When setting a public suffix domain, Appwrite will attempt to issue a valid SSL certificate automatically. When used with a dev domain, Appwrite will assign a self-signed SSL certificate. If you're using a proxy for **localhost development**, such as [ngrok](https://ngrok.com/), this will be the domain of your localhost proxy. |
Copy file name to clipboardExpand all lines: src/routes/docs/apis/graphql/+page.markdoc
+78-98Lines changed: 78 additions & 98 deletions
Original file line number
Diff line number
Diff line change
@@ -1,56 +1,45 @@
1
1
---
2
2
layout: article
3
3
title: GraphQL
4
-
description:
5
-
difficulty: beginner
6
-
readtime: 10
4
+
description: Description used for SEO
7
5
---
8
6
9
-
Appwrite supports multiple protocols for accessing the server, including [REST](/docs/apis/rest), [GraphQL](/docs/apis/graphql), and [Realtime](/docs/apis/realtime). The GraphQL API allows you to query and mutate any resource type on your Appwrite server through the endpoint `/v1/graphql`. Every endpoint available through REST is available through GraphQL, except for OAuth.
7
+
Appwrite supports multiple protocols for accessing the server, including [REST](/docs/rest), [GraphQL](/docs/graphql), and [Realtime](/docs/realtime).
8
+
9
+
The GraphQL API allows you to query and mutate any resource type on your Appwrite server through the endpoint `/v1/graphql`.
10
+
Every endpoint available through REST is available through GraphQL, except for OAuth.
11
+
12
+
## Requests {% #requests %}
13
+
14
+
Although every query executes through the same endpoint, there are multiple ways to make a GraphQL request. All requests, however, share a common structure.
| query | string | **Required**, the GraphQL query to execute. |
19
+
| operationName | string | **Optional**, if the query contains several named operations, controls which one to execute. |
20
+
| variables | object | **Optional**, an object containing variable names and values for the query. Variables are made available to your query with the `$` prefix. |
21
+
22
+
### GraphQL model parameters {% #graphql-model-parameters %}
10
23
11
-
{% info title="GraphQL Model Parameters" %}
12
24
In Appwrite's GraphQL API, all internal model parameters are prefixed with `_` instead of `$` because `$` is reserved by GraphQL.
13
25
14
26
For example, `$collectionId` in the REST API would be referenced as `_collectionId` in the GraphQL API.
15
-
{% /info %}
16
27
17
-
## Requests {% #requests %}
18
-
Although every query executes through the same endpoint, there are multiple ways to make a GraphQL request. All requests, however, share a common structure.
28
+
### GET requests {% #get-resquest %}
19
29
20
-
{% table %}
21
-
* Name {% width=100 %}
22
-
* {% width=100 %}
23
-
* Type {% width=100 %}
24
-
* Description
25
-
---
26
-
* `query`
27
-
* required
28
-
* string
29
-
* The GraphQL query to execute.
30
-
---
31
-
* `operationName`
32
-
* optional
33
-
* string
34
-
* If the query contains several named operations, controls which one to execute.
35
-
---
36
-
* `variables`
37
-
* optional
38
-
* object
39
-
* An object containing variable names and values for the query. Variables are made available to your query with the $ prefix.
40
-
---
41
-
{% /table %}
30
+
You can execute a GraphQL query via a GET request, passing a `query` and optionally `operationName` and `variables` as query parameters.
42
31
43
-
### GET
44
-
You can execute a GraphQL query via a GET request, passing a query and optionally operationName and variables as query parameters.
32
+
### POST requests {% #post-request %}
45
33
46
-
### POST
47
34
There are multiple ways to make a GraphQL POST request, differentiated by content type.
48
35
49
-
#### JSON
36
+
{% tabs %}
37
+
{% tabsitem #json title="JSON" %}
50
38
51
-
There are two ways to make requests with the `application/json` content type. You can send a JSON object containing a `query` and optionally `operationName` and `variables`, or an array of objects with the same structure.
39
+
There are two ways to make requests with the `application/json` content type.
40
+
You can send a JSON object containing a `query` and optionally `operationName` and `variables`, or an array of objects with the same structure.
52
41
53
-
**object**
42
+
#### Object
54
43
55
44
```json
56
45
{
@@ -60,7 +49,7 @@ There are two ways to make requests with the `application/json` content type. Yo
60
49
}
61
50
```
62
51
63
-
**array**
52
+
#### Array
64
53
65
54
```json
66
55
[
@@ -71,9 +60,9 @@ There are two ways to make requests with the `application/json` content type. Yo
71
60
}
72
61
]
73
62
```
63
+
{% /tabsitem %}
74
64
75
-
#### GraphQL
76
-
65
+
{% tabsitem #graphql title="GraphQL" %}
77
66
The `application/graphql` content type can be used to send a query as the raw POST body.
78
67
79
68
```graphql
@@ -84,69 +73,55 @@ query GetAccount {
84
73
}
85
74
}
86
75
```
76
+
{% /tabsitem %}
77
+
{% /tabs %}
87
78
88
-
#### Multipart Form Data
89
79
90
-
The `multipart/form-data` content type can be used to upload files via GraphQL. In this case, the formdata must include the following parts in addition to the files to upload.
80
+
### Multipart formdata {% #multipart-form-data %}
91
81
92
-
{% table %}
93
-
* Name {% width=100 %}
94
-
* {% width=100 %}
95
-
* Type {% width=100 %}
96
-
* Description
97
-
---
98
-
* `operations`
99
-
* required
100
-
* string
101
-
* JSON encoded GraphQL query and optionally operation name and variables. File variables should contain null values.
102
-
---
103
-
* `map`
104
-
* required
105
-
* string
106
-
* JSON encoded map of form-data filenames to the operations dot-path to inject the file to, e.g. variables.file.
107
-
---
108
-
{% /table %}
82
+
The `multipart/form-data` content type can be used to upload files via GraphQL.
83
+
In this case, the form data must include the following parts in addition to the files to upload.
| data | object | The data returned by the query, maps requested field names to their results. |
97
+
| errors | object[] | An array of errors that occurred during the request. |
131
98
132
-
The data object will contain a map of requested field names to their results. If no data is returned, the object will not be present in the response.
99
+
The data object will contain a map of requested field names to their results.
100
+
If no data is returned, the object will not be present in the response.
133
101
134
-
The errors array will contain error objects, each with their own **message** and **path**. The path will contain the field key that is null due to the error. If no errors occur, the array will not be present in the response.
102
+
The errors array will contain error objects, each with their own **message** and **path**.
103
+
The path will contain the field key that is null due to the error.
104
+
If no errors occur, the array will not be present in the response.
135
105
136
106
## Authentication {% #authentication %}
137
-
GraphQL authenticates using Appwrite accounts and sessions. Both accounts and sessions can be created with GraphQL using the `accountCreate`, `accountCreateEmailSession`, `accountCreateAnonymousSession`, or `accountCreatePhoneSession` mutations.
138
107
139
-
More information and examples of authenticating users can be found in the dedicated [authentication guide](/docs/products/auth).
108
+
GraphQL authenticates using Appwrite accounts and sessions.
109
+
Both accounts and sessions can be created with GraphQL using the `accountCreate`, `accountCreateEmailSession`,
110
+
`accountCreateAnonymousSession`, or `accountCreatePhoneSession` mutations.
140
111
141
-
## GraphQL vs REST {% #graphql-vs-rest %}
112
+
More information and examples of authenticating users can be found in the dedicated [authentication guide](/docs/authentication).
113
+
114
+
## GraphQL vs REST {% #graphql-vs-rest %}
142
115
143
116
There are two main features that make GraphQL appealing when compared to the REST API: **selection sets** and **query batching**.
144
117
145
-
### Selection Sets
118
+
### Selection sets {% #selection-sets %}
146
119
147
-
Selection sets can be used to tell a GraphQL API exactly which fields of a particular resource you would like to receive in the response. The server will respond with only those fields, nothing more, nothing less. This gives you full control over what data comes into your application.
120
+
Selection sets can be used to tell a GraphQL API exactly which fields of a particular resource you would like to receive in the response.
121
+
The server will respond with only those fields, nothing more, nothing less. This gives you full control over what data comes into your application.
148
122
149
-
For example, to retrieve only the email of a currently authenticated user, you could query the `accountGet` field, passing only email as the **field selection set**.
123
+
For example, to retrieve only the email of a currently authenticated user, you could query the `accountGet` field,
124
+
passing only email as the **field selection set**.
150
125
151
126
```graphql
152
127
query GetAccount {
@@ -159,7 +134,7 @@ query GetAccount {
159
134
160
135
Given this query, the GraphQL API will respond with:
161
136
162
-
```graphql
137
+
```json
163
138
{
164
139
"data": {
165
140
"accountGet": {
@@ -170,11 +145,13 @@ Given this query, the GraphQL API will respond with:
170
145
}
171
146
```
172
147
173
-
This can be a useful feature for performance, network efficiency, and app responsiveness. As the processing happens on the server, the bandwidth consumed for the request can be dramatically reduced.
148
+
This can be a useful feature for performance, network efficiency, and app responsiveness.
149
+
As the processing happens on the server, the bandwidth consumed for the request can be dramatically reduced.
174
150
175
-
## Query batching {% #query-batching %}
151
+
## Query batching {% #query-batching %}
176
152
177
-
GraphQL allows sending multiple queries or mutations in the same request. There are two different ways to batch queries. The simplest way is to include multiple fields in a single query **or** mutation.
153
+
GraphQL allows sending multiple queries or mutations in the same request.
154
+
There are two different ways to batch queries. The simplest way is to include multiple fields in a single query **or** mutation.
178
155
179
156
```graphql
180
157
query GetAccountAndLocale {
@@ -204,7 +181,8 @@ If both field executions succeed, the response will contain a data key for each
204
181
}
205
182
```
206
183
207
-
If there was no authenticated user, the `accountGet` field would fail to resolve. In such a case the value of the data key for that field will be null, and an object will be added to the errors array instead.
184
+
If there was no authenticated user, the `accountGet` field would fail to resolve.
185
+
In such a case the value of the data key for that field will be null, and an object will be added to the errors array instead.
208
186
209
187
```json
210
188
{
@@ -224,13 +202,16 @@ If there was no authenticated user, the `accountGet` field would fail to resolve
224
202
}
225
203
```
226
204
227
-
Batching with a single query or mutation has some down-sides. You can not mix and match queries and mutations within the same request unless you provide an operationName, in which case you can only execute one query per request.
205
+
Batching with a single query or mutation has some down-sides.
206
+
You cannot mix and match queries and mutations within the same request unless you provide an operationName,
207
+
in which case you can only execute one query per request.
228
208
229
209
Additionally, all **variables** must be passed in the same object, which can be cumbersome and hard to maintain.
230
210
231
-
The second way to batch is to pass an array of queries or mutations in the request. In this way, you can execute queries **and** mutations and keep variables separated for each.
211
+
The second way to batch is to pass an array of queries or mutations in the request.
212
+
In this way, you can execute queries **and** mutations and keep variables separated for each.
0 commit comments