User Tools

Site Tools


tanszek:oktatas:iss_t:graphql_integration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tanszek:oktatas:iss_t:graphql_integration [2025/04/07 16:39] โ€“ created kneheztanszek:oktatas:iss_t:graphql_integration [2025/04/07 16:49] (current) โ€“ [GraphQL Integration] knehez
Line 1: Line 1:
 ==== GraphQL Integration ==== ==== GraphQL Integration ====
- 
-Comparison of main characteristics with REST API. 
  
 Official documentation: Official documentation:
  
 https://graphql.org/learn/ https://graphql.org/learn/
 +
 +Comparison of main characteristics with REST API.
  
 |         | **REST API** | **GraphQL** | |         | **REST API** | **GraphQL** |
Line 79: Line 79:
 The GraphQL Playground will be available at the following URL: The GraphQL Playground will be available at the following URL:
 ๐Ÿ‘‰ http://127.0.0.1:8000/graphql ๐Ÿ‘‰ http://127.0.0.1:8000/graphql
 +
 +----
 +
 +===== Sample Task: Library System with GraphQL =====
 +
 +==== Task Description ====
 +Create a simple GraphQL API to manage data in a library system. The system should store books and authors, and allow adding new books.
 +
 +==== Requirements ====
 +
 +The GraphQL schema should include the following types:
 +
 +  * **Author**:
 +    * `id` (Int)
 +    * `name` (String)
 +
 +  * **Book**:
 +    * `id` (Int)
 +    * `title` (String)
 +    * `author` (Author)
 +    * `year` (Int)
 +
 +==== Features to Implement ====
 +
 +  * **Queries:**
 +    * List all books (title, author name, year)
 +    * List books by a specific author (searched by name)
 +
 +  * **Mutations:**
 +    * Add a new book with the following fields: title, author ID, year
 +
 +==== Example Query ====
 +
 +<code javascript>
 +query {
 +  books {
 +    title
 +    author {
 +      name
 +    }
 +    year
 +  }
 +}
 +</code>
 +
 +==== Example Mutation ====
 +
 +<code javascript>
 +mutation {
 +  addBook(title: "1984", authorId: 1, year: 1949) {
 +    id
 +    title
 +    author {
 +      name
 +    }
 +  }
 +}
 +</code>
 +
 +==== Technical Requirements ====
 +
 +  * Use **FastAPI** and **Strawberry GraphQL** libraries
 +  * Store data using built-in lists (e.g., `authors`, `books`)
 +  * The GraphQL endpoint should be accessible at `http://127.0.0.1:8000/graphql`
 +
 +==== Bonus ====
 +
 +  * Implement a new mutation to add an author by name
 +  * Implement a query to list books by a given year
 +
  
tanszek/oktatas/iss_t/graphql_integration.1744043945.txt.gz ยท Last modified: 2025/04/07 16:39 by knehez