Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an aws chalice integration #923

Merged
merged 43 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9a41fee
added chalice to the project requirements
mcsheehan May 8, 2021
6e0f6dd
added a chalice compatible GraphQLView
mcsheehan May 8, 2021
d3085ad
added to the chalice view and added unit tests for chalice
mcsheehan May 9, 2021
1339aba
Updated the poetry lock file
mcsheehan May 9, 2021
bb993cb
Update strawberry/chalice/views.py
mcsheehan May 9, 2021
aafe389
used pathlib to import the graphiql file
mcsheehan May 9, 2021
ac49dd0
Update strawberry/chalice/views.py
mcsheehan May 9, 2021
7b9cfce
Added the return type and simplified get and post methods
mcsheehan May 9, 2021
5c2c935
Merge pull request #1 from strawberry-graphql/main
mcsheehan Jul 8, 2021
19c5f5d
added chalice to the project requirements
mcsheehan May 8, 2021
387a497
added a chalice compatible GraphQLView
mcsheehan May 8, 2021
997be85
added to the chalice view and added unit tests for chalice
mcsheehan May 9, 2021
23bba74
Updated the poetry lock file
mcsheehan May 9, 2021
c0e19d9
Update strawberry/chalice/views.py
mcsheehan May 9, 2021
203c335
used pathlib to import the graphiql file
mcsheehan May 9, 2021
94a5e7a
Update strawberry/chalice/views.py
mcsheehan May 9, 2021
24355f8
Added the return type and simplified get and post methods
mcsheehan May 9, 2021
bf5485d
Merge remote-tracking branch 'origin/feature/chalice' into feature/ch…
Jul 8, 2021
5c360a5
Added a chalice integration, documentation and tests
mcsheehan Jul 14, 2021
ea7fbc7
Merge branch 'main' into feature/chalice
patrick91 Aug 15, 2021
71e64ba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 15, 2021
942b924
Update release notes
patrick91 Aug 15, 2021
dc15c4c
Remove useless file
patrick91 Aug 15, 2021
ecba735
Ignore typing issue
patrick91 Aug 15, 2021
2810918
Rename test folder
patrick91 Aug 15, 2021
ad88643
Disable MyPy cache
patrick91 Aug 15, 2021
ab5de9a
Added a line to the documentation and removed the unneeded lru_cache
mcsheehan Nov 23, 2021
8b5edcc
Added many unit tests to improve test coverage
mcsheehan Nov 23, 2021
3e1d468
Merge branch 'strawberry-graphql:main' into main
Nov 23, 2021
f4361da
Merge branch 'main' into feature/chalice
mcsheehan Nov 23, 2021
07f00df
ran poetry lock --no-update
mcsheehan Nov 23, 2021
5d6027d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 23, 2021
00b979f
Updated the release notes
mcsheehan Nov 23, 2021
8000682
Merge remote-tracking branch 'origin/feature/chalice' into feature/ch…
mcsheehan Nov 23, 2021
a0df66b
Move release to minor
patrick91 Nov 23, 2021
9818374
Merge branch 'main' into feature/chalice
patrick91 Nov 23, 2021
6a508fb
Run MyPy on 3.10
patrick91 Nov 23, 2021
a2bd8c5
Add type ignore to prevent mypy from failing
patrick91 Nov 23, 2021
781daf6
Move mypy to its own workflow and add cache
patrick91 Nov 23, 2021
c007d4d
Fix mypy
patrick91 Nov 23, 2021
5cb5f78
Test removing cache
patrick91 Nov 23, 2021
3bf7b2c
Only check mypy on main codebase
patrick91 Nov 23, 2021
c844376
Rename pipeline
patrick91 Nov 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: MyPy

on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "strawberry/**"
- "tests/**"
- ".github/workflows/mypy.yml"

jobs:
mypy:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-python@v2
id: setup-python
with:
python-version: '3.10'
architecture: x64

- uses: actions/checkout@v2

- run: pip install poetry
- run: poetry config experimental.new-installer false

- name: "Python dependencies cache"
id: cache-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-poetry-

- name: Install dependencies
run: poetry install
if: steps.cache-poetry-dependencies.outputs.cache-hit != 'true'

- run: poetry run mypy --ignore-missing-imports --config-file mypy.ini --install-types --non-interactive --show-traceback strawberry
15 changes: 0 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,3 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true

mypy:
runs-on: ubuntu-latest
container: python:3.9

steps:
- uses: actions/checkout@v2

- run: pip install poetry
- run: poetry config experimental.new-installer false

- name: Install dependencies
run: poetry install

- run: poetry run mypy --ignore-missing-imports --config-file mypy.ini --install-types --non-interactive --show-traceback .
6 changes: 6 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Release type: minor

This release adds support for AWS Chalice. A framework for deploying serverless applications using AWS.

A view for aws chalice has been added to the strawberry codebase.
This view embedded in a chalice app allows anyone to get a GraphQL API working and hosted on AWS in minutes using a serverless architecture.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- [FastAPI](./integrations/fastapi.md)
- [Flask](./integrations/flask.md)
- [Sanic](./integrations/sanic.md)
- [Chalice](./integrations/chalice.md)
- [Starlette](./integrations/starlette.md)
- [Pydantic **experimental**](./integrations/pydantic.md)

Expand Down
68 changes: 68 additions & 0 deletions docs/integrations/chalice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: Chalice
---

# Chalice

Strawberry comes with an AWS Chalice integration. It provides a view that you can
use to serve your GraphQL schema:

Use the Chalice CLI to create a new project

```shell
chalice new-project badger-project
cd badger-project
```

Replace the contents of app.py with the following:

```python
from chalice import Chalice
from chalice.app import Request, Response

import strawberry
from strawberry.chalice.views import GraphQLView

app = Chalice(app_name="BadgerProject")


@strawberry.type
class Query:
@strawberry.field
def greetings(self) -> str:
return "hello from the illustrious stack badger"


@strawberry.type
class Mutation:
@strawberry.mutation
def echo(self, string_to_echo: str) -> str:
return string_to_echo


schema = strawberry.Schema(query=Query, mutation=Mutation)
view = GraphQLView(schema=schema, render_graphiql=True)


@app.route("/graphql", methods=["GET", "POST"], content_types=["application/json"])
def handle_graphql() -> Response:
request: Request = app.current_request
result = view.execute_request(request)
return result

```

And then run `chalice local` to start the localhost

```shell
chalice local
```

The GraphiQL interface can then be opened in your browser on http://localhost:8000/graphql

## Options

The `GraphQLView` accepts two options at the moment:

- `schema`: mandatory, the schema created by `strawberry.Schema`.
- `graphiql`: optional, defaults to `True`, whether to enable the GraphiQL interface.
Loading