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

Subgraph: "'NoneType' object has no attribute '...'" #3506

Closed
dgram opened this issue May 21, 2024 · 4 comments
Closed

Subgraph: "'NoneType' object has no attribute '...'" #3506

dgram opened this issue May 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@dgram
Copy link

dgram commented May 21, 2024

When i make use of subgraphs i can start the graphql server, also the docs generated successfully but when i execute a query i get the error "'NoneType' object has no attribute '...'"

@strawberry.type
class TestType:
    name: str

@strawberry.type
class TestQuery:
    @strawberry.field()
    async def test() -> TestType:
        return TestType(name="test")

@strawberry.type
class Query:
    sub: TestQuery = strawberry.field(default_factory=TestQuery)

graphql_app = GraphQL(
    strawberry.Schema(
        query=Query
    )
)
# ... other fastapi graphql connection here

# query
query MyQuery {
  sub {
    test {
      name
    }
  }
}

System Information

  • Operating system: MacOS
  • Strawberry version: 0.229.1

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@dgram dgram added the bug Something isn't working label May 21, 2024
@patrick91
Copy link
Member

@dgram to make this work you need to have a root value 😊 we don't instantiate the query type 😊

https://strawberry.rocks/docs/integrations/fastapi#root_value_getter

@dgram
Copy link
Author

dgram commented May 28, 2024

hey @patrick91 thanks for your response, what did you mean with this? i can't found an answer about this case

@patrick91
Copy link
Member

@dgram
Copy link
Author

dgram commented May 29, 2024

thanks, i've found the answer. because i don't have any fields to set per default this is the right answer.

@strawberry.type
class Query:
    sub: TestQuery = strawberry.field(resolver=lambda: TestQuery())

@dgram dgram closed this as completed May 29, 2024
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

No branches or pull requests

2 participants