Skip to content

Commit

Permalink
Add Strawberry GraphQL schema (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
devennavani authored Jan 17, 2024
1 parent effcef6 commit 82a97ba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 0 additions & 1 deletion backend/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse

from modal import Image, Stub, asgi_app

web_app = FastAPI()
Expand Down
19 changes: 19 additions & 0 deletions backend/graphql/query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import strawberry
from typing import List

@strawberry.type
class Book:
title: str
author: str

def get_books():
return [
Book(
title="The Great Gatsby",
author="F. Scott Fitzgerald",
),
]

@strawberry.type
class Query:
books: List[Book] = strawberry.field(resolver=get_books)
7 changes: 7 additions & 0 deletions backend/graphql/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import strawberry

from .query import Query

schema = strawberry.Schema(
query=Query
)
8 changes: 8 additions & 0 deletions frontend/src/graphql/__generated__/schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82a97ba

Please sign in to comment.