tartiflette-aiohttp v0.8.0 Release Notes
Release Date: 2019-06-18 // almost 5 years ago-
[0.8.0] - 2019-06-17
🔄 Changed
- ⬆️ Bump
tartiflette
version to <0.12.0,>=0.11.0. - ⚡️ Update to the new
create_engine
API, breaking the way theengine
parameter works.
Before it was possible to do:
from tartiflette import Engineengine = Engine(sdl)ctx = { 'user\_service': user\_service}web.run\_app( register\_graphql\_handlers( app=web.Application(), engine=engine, executor\_context=ctx, executor\_http\_endpoint='/graphql', executor\_http\_methods=['POST', 'GET'] ) )
Typically you were able to provide your own already initialized
Engine
Instance.
Now the engine is issued by the coroutine returning methodcreate_engine
.You have 3 choice in order to provide your own Engine :
Provide a non-awaited create_engine
from tartiflette import create\_engineengine = create\_engine(sdl)ctx = { 'user\_service': user\_service}web.run\_app( register\_graphql\_handlers( app=web.Application(), engine=engine, executor\_context=ctx, executor\_http\_endpoint='/graphql', executor\_http\_methods=['POST', 'GET'] ) )
register_graphql_handlers
will await that coroutine. (It can be any coroutine that respect the create_engine prototype)Provide your own instance of child class of Engine
from tartiflette import Engineclass myEngine(Engine): def \_\_init\_\_(self, my, parameters): super().\_\_init\_\_() self.\_my = myself.\_parameters = parametersasync def cook( self, sdl: Union[str, List[str]], error\_coercer: Callable[[Exception], dict] = None, custom\_default\_resolver: Optional[Callable] = None, modules: Optional[Union[str, List[str]]] = None, schema\_name: str = "default", ): await super().cook( sdl, error\_coercer, custom\_default\_resolver, modules, schema\_name ) print(self.\_my, self.\_parameters)ctx = { 'user\_service': user\_service}web.run\_app( register\_graphql\_handlers( app=web.Application(), engine=myEngine(my, parameters), executor\_context=ctx, executor\_http\_endpoint='/graphql', executor\_http\_methods=['POST', 'GET'] ) )
Provide you instance of an Engine class composed with an Engine
from tartiflette import Engineclass myEngine: def \_\_init\_\_(self, my, parameters): self.\_engine = Engine() self.\_my = myself.\_parameters = parametersasync def cook( self, sdl: Union[str, List[str]], error\_coercer: Callable[[Exception], dict] = None, custom\_default\_resolver: Optional[Callable] = None, modules: Optional[Union[str, List[str]]] = None, schema\_name: str = "default", ): print(self.\_my) await self.\_engine.cook( sdl, error\_coercer, custom\_default\_resolver, modules, schema\_name ) print(self.\_parameters) async def execute( self, query: str, operation\_name: Optional[str] = None, context: Optional[Dict[str, Any]] = None, variables: Optional[Dict[str, Any]] = None, initial\_value: Optional[Any] = None, ): return await self.\_engine.execute( query, operation\_name, context, variables, initial\_value )ctx = { 'user\_service': user\_service}web.run\_app( register\_graphql\_handlers( app=web.Application(), engine=myEngine(my, parameters), executor\_context=ctx, executor\_http\_endpoint='/graphql', executor\_http\_methods=['POST', 'GET'] ) )
- ⬆️ Bump