-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from simonsobs/dev
Add an internal plugin `dev`
- Loading branch information
Showing
5 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__all__ = ['Plugin'] | ||
|
||
from .plugin import Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from apluggy import PluginManager | ||
from dynaconf import Dynaconf | ||
|
||
from nextlinegraphql.hook import spec | ||
|
||
from .schema import Query | ||
|
||
|
||
class Plugin: | ||
@spec.hookimpl | ||
def configure(self, settings: Dynaconf, hook: PluginManager) -> None: | ||
self._settings = settings | ||
|
||
@spec.hookimpl | ||
def schema(self): | ||
return (Query, None, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__all__ = ['Query'] | ||
|
||
from .query import Query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
from typing import cast | ||
|
||
import strawberry | ||
from starlette.requests import Request | ||
from strawberry.types import Info | ||
|
||
|
||
def query_headers(info: Info) -> str: | ||
request = cast(Request, info.context['request']) | ||
return json.dumps(dict(request.headers)) | ||
|
||
|
||
@strawberry.type | ||
class QueryDev: | ||
headers: str = strawberry.field(resolver=query_headers) | ||
|
||
|
||
@strawberry.type | ||
class Query: | ||
@strawberry.field | ||
def dev(self) -> QueryDev: | ||
return QueryDev() |