Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manojtharindu11/graphql
This repository consist of simple GraphQL concepts like create typeDefs, resolvers and mutaions using JavaScript.
https://github.com/manojtharindu11/graphql
apollo-server graphql mutations query
Last synced: 10 days ago
JSON representation
This repository consist of simple GraphQL concepts like create typeDefs, resolvers and mutaions using JavaScript.
- Host: GitHub
- URL: https://github.com/manojtharindu11/graphql
- Owner: manojtharindu11
- Created: 2025-01-11T05:10:30.000Z (23 days ago)
- Default Branch: main
- Last Pushed: 2025-01-15T09:59:09.000Z (18 days ago)
- Last Synced: 2025-01-15T11:43:47.452Z (18 days ago)
- Topics: apollo-server, graphql, mutations, query
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# **GraphQL**
A brief summary of the GraphQL concepts I’ve explored:
### **1. Schema and Types**
Defines API structure using `Query`, `Mutation`, and custom types.
```graphql
type Game {
id: ID!,
title: String!,
platform: [String!]!
reviews: [Review!]
}
type Review {
id: ID!,
rating: Int!,
content: String!,
game: Game!,
author: Author!
}
type Author {
id: ID!,
name: String!,
verified: Boolean!,
reviews: [Review!]
}
```### **2. Resolver Functions**
Fetches data for schema fields.
```javascript
Query: {
games() {
return db.games;
},
game(_, args) {
return db.games.find((game) => game.id === args.id);
},
reviews() {
return db.reviews;
},
review(_, args) {
return db.reviews.find((review) => review.id === args.id);
},
authors() {
return db.authors;
},
author(_, args) {
return db.authors.find((author) => author.id === args.id);
},
}
```### **3. Query Variables**
Enable dynamic queries.
```graphql
query GamesQuery($id: ID!) {
game(id: $id) {
title,
platform,
reviews {
content,
rating
}
}}
```### **4. Related Data**
Fetch nested relationships.
```graphql
type Game {
reviews: [Review!]
}
```### **5. Mutations**
Perform data operations like add, update, or delete.
```graphql
mutation AddMutation($game: AddGameInput!) {
addGame(game: $game) {
id,
title,
platform
}
}
```