From 85569c38da53f837424e9a422444725a8caf3632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 1 Sep 2022 10:31:53 +0200 Subject: [PATCH 1/5] Create GraphQL-Playground.md --- backend/src/graphql/GraphQL-Playground.md | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 backend/src/graphql/GraphQL-Playground.md diff --git a/backend/src/graphql/GraphQL-Playground.md b/backend/src/graphql/GraphQL-Playground.md new file mode 100644 index 000000000..3381f4e9e --- /dev/null +++ b/backend/src/graphql/GraphQL-Playground.md @@ -0,0 +1,28 @@ +# GraphQL Playground + +To use the GraphQL Playground we have to know some basics: + +## How To Login? + +At first we have to have a user of ocelot.social as whom we can login. +The user can be created by seeding the Neo4j database from the backend or by several GraphQL mutations. + +### Seed The Neo4j Database + +In your browser you reach the GraphQL Playground under `http://localhost:4000/` +if the database and the backend is running, see [backend](../../backend/README.md). +You can find how to seed there as well. + +### Use GraphQL Mutations To Create A User + +TODO: Describe how to create a user by GraphQL mutations! + +### Login Via GraphQL + +You can login by sending the query: + +```gql +mutation ($email: String!, $password: String!) { + login(email: $email, password: $password) +} +``` From 1f6beffa6f23edde1241eda1758f9fef224285f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 1 Sep 2022 10:32:36 +0200 Subject: [PATCH 2/5] Create GraphQL-Playground.md --- backend/src/GraphQL-Playground.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 backend/src/GraphQL-Playground.md diff --git a/backend/src/GraphQL-Playground.md b/backend/src/GraphQL-Playground.md new file mode 100644 index 000000000..3381f4e9e --- /dev/null +++ b/backend/src/GraphQL-Playground.md @@ -0,0 +1,28 @@ +# GraphQL Playground + +To use the GraphQL Playground we have to know some basics: + +## How To Login? + +At first we have to have a user of ocelot.social as whom we can login. +The user can be created by seeding the Neo4j database from the backend or by several GraphQL mutations. + +### Seed The Neo4j Database + +In your browser you reach the GraphQL Playground under `http://localhost:4000/` +if the database and the backend is running, see [backend](../../backend/README.md). +You can find how to seed there as well. + +### Use GraphQL Mutations To Create A User + +TODO: Describe how to create a user by GraphQL mutations! + +### Login Via GraphQL + +You can login by sending the query: + +```gql +mutation ($email: String!, $password: String!) { + login(email: $email, password: $password) +} +``` From 9ac943d11d48b613ab565c8267017182ebd7d426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 1 Sep 2022 10:57:16 +0200 Subject: [PATCH 3/5] Delete GraphQL-Playground.md --- backend/src/GraphQL-Playground.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 backend/src/GraphQL-Playground.md diff --git a/backend/src/GraphQL-Playground.md b/backend/src/GraphQL-Playground.md deleted file mode 100644 index 3381f4e9e..000000000 --- a/backend/src/GraphQL-Playground.md +++ /dev/null @@ -1,28 +0,0 @@ -# GraphQL Playground - -To use the GraphQL Playground we have to know some basics: - -## How To Login? - -At first we have to have a user of ocelot.social as whom we can login. -The user can be created by seeding the Neo4j database from the backend or by several GraphQL mutations. - -### Seed The Neo4j Database - -In your browser you reach the GraphQL Playground under `http://localhost:4000/` -if the database and the backend is running, see [backend](../../backend/README.md). -You can find how to seed there as well. - -### Use GraphQL Mutations To Create A User - -TODO: Describe how to create a user by GraphQL mutations! - -### Login Via GraphQL - -You can login by sending the query: - -```gql -mutation ($email: String!, $password: String!) { - login(email: $email, password: $password) -} -``` From 13cd81fcf5a8e6493e79bce6f63aa03cb9d97b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 1 Sep 2022 12:06:28 +0200 Subject: [PATCH 4/5] Update GraphQL-Playground.md --- backend/src/graphql/GraphQL-Playground.md | 100 +++++++++++++++++++--- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/backend/src/graphql/GraphQL-Playground.md b/backend/src/graphql/GraphQL-Playground.md index 3381f4e9e..af248f112 100644 --- a/backend/src/graphql/GraphQL-Playground.md +++ b/backend/src/graphql/GraphQL-Playground.md @@ -1,28 +1,108 @@ # GraphQL Playground -To use the GraphQL Playground we have to know some basics: +To use GraphQL Playground, we need to know some basics: ## How To Login? -At first we have to have a user of ocelot.social as whom we can login. -The user can be created by seeding the Neo4j database from the backend or by several GraphQL mutations. +First, we need to have a user from ocelot.social to log in as. +The user can be created by seeding the Neo4j database from the backend or by multiple GraphQL mutations. ### Seed The Neo4j Database -In your browser you reach the GraphQL Playground under `http://localhost:4000/` -if the database and the backend is running, see [backend](../../backend/README.md). -You can find how to seed there as well. +In your browser you can reach the GraphQL Playground under `http://localhost:4000/`, if the database and the backend are running, see [backend](../../README.md). +There you will also find instructions on how to seed the database. ### Use GraphQL Mutations To Create A User -TODO: Describe how to create a user by GraphQL mutations! +TODO: Describe how to create a user using GraphQL mutations! ### Login Via GraphQL -You can login by sending the query: +You can register a user by sending the query: ```gql -mutation ($email: String!, $password: String!) { - login(email: $email, password: $password) +mutation { + login(email: "user@example.org", password: "1234") } ``` + +Or use `"moderator@example.org"` or `"admin@example.org"` for the roll you need. + +If all goes well, you will receive a QGL response like: + +```json +{ + "data": { + "login": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InUzIiwibmFtZSI6Ikplbm55IFJvc3RvY2siLCJzbHVnIjoiamVubnktcm9zdG9jayIsImlhdCI6MTY2MjAyMzMwNSwiZXhwIjoxNzI1MTM4NTA1LCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQwMDAiLCJzdWIiOiJ1MyJ9.atBS-SOeS784HPeFl_5s8sRWehEAU1BkgcOZFD8d4bU" + } +} +``` + +You can use this response to set an HTTP header when you click `HTTP HEADERS` in the footer. +Just set it with the login token you received in response: + +```json +{ + "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InUzIiwibmFtZSI6Ikplbm55IFJvc3RvY2siLCJzbHVnIjoiamVubnktcm9zdG9jayIsImlhdCI6MTY2MjAyMzMwNSwiZXhwIjoxNzI1MTM4NTA1LCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQwMDAiLCJzdWIiOiJ1MyJ9.atBS-SOeS784HPeFl_5s8sRWehEAU1BkgcOZFD8d4bU" +} +``` + +This token is used for all other queries and mutations you send to the backend. + +## Query And Mutate + +When you are logged in and open a new playground tab by clicking "+", you can create a new group by sending the following mutation: + +```gql +mutation { + CreateGroup( + # id: "" + name: "My Group" + # slug: "" + about: "We will save the world" + description: "

English:

This group is hidden.

What is our group for?

This group was created to allow investigative journalists to share and collaborate.

How does it work?

Here you can internally share posts and comments about them.


Deutsch:

Diese Gruppe ist verborgen.

Wofür ist unsere Gruppe?

Diese Gruppe wurde geschaffen, um investigativen Journalisten den Austausch und die Zusammenarbeit zu ermöglichen.

Wie funktioniert das?

Hier könnt ihr euch intern über Beiträge und Kommentare zu ihnen austauschen.

" + groupType: hidden + actionRadius: interplanetary + categoryIds: ["cat12"] + ) { + id + name + slug + createdAt + updatedAt + disabled + deleted + about + description + groupType + actionRadius + myRole + } +} +``` + +You will receive the answer: + +```json +{ + "data": { + "CreateGroup": { + "id": "2e3bbadb-804b-4ebc-a673-2d7c7f05e827", + "name": "My Group", + "slug": "my-group", + "createdAt": "2022-09-01T09:44:47.969Z", + "updatedAt": "2022-09-01T09:44:47.969Z", + "disabled": false, + "deleted": false, + "about": "We will save the world", + "description": "

English:

This group is hidden.

What is our group for?

This group was created to allow investigative journalists to share and collaborate.

How does it work?

Here you can internally share posts and comments about them.


Deutsch:

Diese Gruppe ist verborgen.

Wofür ist unsere Gruppe?

Diese Gruppe wurde geschaffen, um investigativen Journalisten den Austausch und die Zusammenarbeit zu ermöglichen.

Wie funktioniert das?

Hier könnt ihr euch intern über Beiträge und Kommentare zu ihnen austauschen.

", + "groupType": "hidden", + "actionRadius": "interplanetary", + "myRole": "owner" + } + } +} +``` + +If you look into the Neo4j database with your browser and search the groups, you will now also find your new group. +For more details about our Neo4j database read [here](../../../neo4j/README.md). From 28a742574c889f4b850f0d3fcfdd4eee21b8f7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 1 Sep 2022 12:15:30 +0200 Subject: [PATCH 5/5] Update README.md --- backend/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/README.md b/backend/README.md index 6d837856c..083606b09 100644 --- a/backend/README.md +++ b/backend/README.md @@ -60,6 +60,7 @@ your `.env` configuration file. Your backend is up and running at [http://localhost:4000/](http://localhost:4000/) This will start the GraphQL service \(by default on localhost:4000\) where you can issue GraphQL requests or access GraphQL Playground in the browser. +More details about our GraphQL playground and how to use it with ocelot.social can be found [here](./src/graphql/GraphQL-Playground.md). ![GraphQL Playground](../.gitbook/assets/graphql-playground.png)