Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yerlinmatu/courses-api-graphql
Learning GraphQL
https://github.com/yerlinmatu/courses-api-graphql
courses graphql-api nodejs-server
Last synced: 6 days ago
JSON representation
Learning GraphQL
- Host: GitHub
- URL: https://github.com/yerlinmatu/courses-api-graphql
- Owner: YerlinMatu
- License: mit
- Created: 2020-01-18T17:19:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T21:07:06.000Z (almost 2 years ago)
- Last Synced: 2023-03-11T14:29:11.220Z (over 1 year ago)
- Topics: courses, graphql-api, nodejs-server
- Language: JavaScript
- Size: 548 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Courses API
### Instalación
``` npm install ```
### Ejecución en Dev
``` npm run dev ```
### Ejecución en Prod
``` npm run start ```### Configuración de base de datos
- Configuración de base de datos
- Creen una cuenta en MongoDB Atlas
- Creen un nuevo cluster
- En el nuevo cluster, hagan click en Connect
- Coloquen en lista blanca su IP
- Creen un usuario para la BD con su contraseña
- Creen un nuevo enlace de conexión
- En Robot3t hagan click en Create en la ventana MongoDB Connections
- Peguen el enlace de conexión generado en (3.2)
- Hagan click en From SRV
- Hagan click en Connect en la ventana MongoDB Connections# Queries ejecutadas en el curso en GraphiQL
## Alias y Fragments
```graphql
{
AllCourses: getCourses{
...CourseFields
}Course1: getCourse(id: "5cb4b8ce75f954a0585f7be2"){
...CourseFields
teacher
}Course2: getCourse(id: "5cb4b8ce75f954a0585f7be4"){
...CourseFields
topic
}
}fragment CourseFields on Course {
_id
title
description
people {
_id
name
}
}
```## Variables
```graphql
query GetCourse2 ($course: ID!) {
getCourse(id: $course){
_id
title
people{
_id
name
}
}
}
```Requiere un objeto JSON como:
```json
{
"course": "5cb4b8ce75f954a0585f7be3"
}
```## Interfaces
```graphql
{
getPeople{
_id
name
... on Monitor {
phone
}
... on Student {
avatar
}
}
}
```## Directivas
```graphql
query getPeopleData($monitor: Boolean!, $avatar: Boolean!){
getPeople{
_id
name
... on Monitor @include(if: $monitor) {
phone
}
... on Student @include(if: $avatar) {
avatar
}
}
}
```Requiere un objeto JSON como:
```json
{
"monitor": false,
"avatar": true
}
```## Unions
```graphql
{
searchItems(keyword: "1"){
__typename
... on Course {
title
description
}
... on Monitor {
name
phone
}
... on Student {
name
}
}
}
```