question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenAPI schema for ariadne routes is not generated by starlette

See original GitHub issue

We’re trying to generate an OpenAPI schema using starlette.schemas.SchemaGenerator, however it does not include any definitions for ariadne.

As per starlette’s docs:

Schema generation works by inspecting the routes on the application through app.routes, and using the docstrings or other attributes on the endpoints in order to determine a complete API schema.

Is it possible to add a docstring into ariadne’s graphql endpoint, or allow it to be configured manually so that it can be picked up by ariadne’s schema generator?

EDIT: One possible workaround is to wrap ariadne’s route with another route, but it would be great if this was available out of the box. EDIT 2: Seems like SchemaGenerator.get_endpoints doesn’t find ariadne’s endpoints. We’re using it as follows:

class GraphQLAdapter(Starlette):
    SCHEMA_PATH = ...

    def __init__(self):
        ...
        schema = make_executable_schema(...)
        graphql = GraphQL(schema)

        super().__init__(
            routes=[
                Mount('', graphql),
            ],
        )

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rafalpcommented, Nov 18, 2022

We could potentially create property(routes) and use that, but then we will have an ASGI app that creates Starlette routes that wrap its methods and that doesn’t sound like good approach to me.

0reactions
and3rsoncommented, Nov 18, 2022

@rafalp - totally agree. This sounds like something that needs to be done in starlette. I’ve started a discussion for this: https://github.com/encode/starlette/discussions/1958

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · mirumee/ariadne - GitHub
Python library for implementing GraphQL servers using schema-first approach. ... OpenAPI schema for ariadne routes is not generated by starlette.
Read more >
API Schemas - Starlette
Schema generation works by inspecting the routes on the application through app.routes , and using the docstrings or other attributes on the endpoints...
Read more >
tiangolo/fastapi - Gitter
I have created two routes GET and PUT . PUT appends an item to a global list and GET returns that list. I...
Read more >
Starlette integration - Ariadne GraphQL
Ariadne is an ASGI application that can be directly mounted under Starlette. It will support both HTTP and WebSocket traffic used by subscriptions:...
Read more >
GraphQL - FastAPI
FastAPI framework, high performance, easy to learn, fast to code, ready for production.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found