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

Cannot resolve extended types #292

Closed
remorses opened this issue Sep 14, 2019 · 1 comment · Fixed by #293
Closed

Cannot resolve extended types #292

remorses opened this issue Sep 14, 2019 · 1 comment · Fixed by #293
Assignees
Labels
bug Something isn't working
Milestone

Comments

@remorses
Copy link

With the schema

type Query {
    hello: String
}

extend type Query {
    world: String
}

I can see the extended fields in graphiql schema but as soon as i try to declare a resolver for the extended type like this

@Resolver('Query.world')
async def revolve_stuff(_, args, ctx, info):
    return 'hi'

baking the schema i get the error

Traceback (most recent call last):
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/schema/schema.py", line 348, in get_field_by_name
    return self.type_definitions[parent_name].find_field(field_name)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/types/object.py", line 125, in find_field
    return self.implemented_fields[name]
KeyError: 'world'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/morse/Documents/GitHub/play-tartiflette/src/__main__.py", line 54, in <module>
    run()
  File "/Users/morse/Documents/GitHub/play-tartiflette/src/__main__.py", line 52, in run
    web.run_app(app, port=8090,)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/aiohttp/web.py", line 415, in run_app
    reuse_port=reuse_port))
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/aiohttp/web.py", line 287, in _run_app
    await runner.setup()
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/aiohttp/web_runner.py", line 203, in setup
    self._server = await self._make_server()
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/aiohttp/web_runner.py", line 302, in _make_server
    await self._app.startup()
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/aiohttp/web_app.py", line 389, in startup
    await self.on_startup.send(self)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/aiohttp/signals.py", line 34, in send
    await receiver(*args, **kwargs)  # type: ignore
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette_aiohttp/__init__.py", line 97, in _cook_on_startup
    sdl=sdl, schema_name=schema_name, modules=modules
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/engine.py", line 250, in cook
    schema_name, custom_default_resolver, custom_default_type_resolver
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 65, in bake
    schema = SchemaBakery._preheat(schema_name)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 39, in _preheat
    obj.bake(schema)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/resolver/resolver.py", line 67, in bake
    field = schema.get_field_by_name(self.name)
  File "/Users/morse/.pyenv/versions/3.7.2/lib/python3.7/site-packages/tartiflette/schema/schema.py", line 351, in get_field_by_name
    f"field `{name}` was not found in GraphQL schema."
tartiflette.types.exceptions.tartiflette.UnknownSchemaFieldResolver: field `Query.world` was not found in GraphQL schema.

I am using the last published 1.0.0rc1 together with tartiflette-aiohttp==1.0.0

@Maximilien-R Maximilien-R self-assigned this Sep 14, 2019
@Maximilien-R Maximilien-R added the bug Something isn't working label Sep 14, 2019
@Maximilien-R Maximilien-R added this to the road-to-v1 milestone Sep 14, 2019
@Maximilien-R
Copy link
Member

Hi @remorses,

Thank you for raising this issue.

Indeed, defining a resolver on an extended field of a type raises an exception. This is due to the fact that resolvers are cooked before cooking the extensions.

This behavior should be fix with this PR.

You can test it with this development release:

pip install --extra-index-url https://test.pypi.org/simple/ tartiflette==1.0.0rc1.dev1568489057

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants