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

Document graphql_type on @strawberry.field #3698

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/general/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ class Query:
return "Strawberry"
```

The decorator syntax supports specifying a `graphql_type` for cases when the
return type of the function does not match the GraphQL type:

```python
class User:
id: str
name: str

def __init__(self, id: str, name: str):
self.id = id
self.name = name

@strawberry.type(name="User")
class UserType:
id: strawberry.ID
name: str

@strawberry.type
class Query:
@strawberry.field(graphql_type=UserType)
def user(self) -> User
return User(id="ringo", name="Ringo")
```

## Arguments

GraphQL fields can accept arguments, usually to filter out or retrieve specific
Expand Down
Loading