Skip to content

Commit

Permalink
Change 'id' argument's type to ID in site query
Browse files Browse the repository at this point in the history
  • Loading branch information
Ester Beltrami committed Aug 30, 2023
1 parent 4a7fc4e commit 0b72e6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions grapple/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def inner(cls):
field_type = lambda: registry.models[cls] # noqa: E731
field_query_params = query_params
if field_query_params is None:
field_query_params = {"id": graphene.Int()}
field_query_params = {"id": graphene.ID()}

if issubclass(cls, Page):
field_query_params["slug"] = graphene.Argument(
Expand Down Expand Up @@ -194,7 +194,7 @@ def inner(cls):
field_type = lambda: registry.models[cls] # noqa: E731
field_query_params = query_params
if field_query_params is None:
field_query_params = {"id": graphene.Int()}
field_query_params = {"id": graphene.ID()}

if issubclass(cls, Page):
field_query_params["slug"] = graphene.Argument(
Expand Down
2 changes: 1 addition & 1 deletion grapple/types/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SiteObjectType(DjangoObjectType):
)
page = graphene.Field(
PageInterface,
id=graphene.Int(),
id=graphene.ID(),
slug=graphene.String(),
url_path=graphene.String(),
token=graphene.String(),
Expand Down
10 changes: 5 additions & 5 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_query_field_plural(self):

def test_query_field(self):
query = """
query ($id: Int, $urlPath: String, $slug: String) {
query ($id: ID, $urlPath: String, $slug: String) {
post(id: $id, urlPath: $urlPath, slug: $slug) {
id
urlPath
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_query_field(self):

def test_multiple_middleware(self):
query = """
query ($id: Int) {
query ($id: ID) {
middlewareModel(id: $id) {
id
}
Expand Down Expand Up @@ -178,7 +178,7 @@ def setUp(self):

def test_paginated_query_field(self):
query = """
query ($id: Int, $urlPath: String, $slug: String) {
query ($id: ID, $urlPath: String, $slug: String) {
blogPage(id: $id, urlPath: $urlPath, slug: $slug) {
id
urlPath
Expand Down Expand Up @@ -476,7 +476,7 @@ def test_query_field_with_logged_in_user_should_return_nothing(self):
"""

query = """
query ($id: Int) {
query ($id: ID) {
post(id: $id) {
id
urlPath
Expand Down Expand Up @@ -514,7 +514,7 @@ def test_paginated_query_field_with_logged_in_user_should_return_nothing(self):
The query field was registered with the anonymous middleware, i.e. requires only anonymous users
"""
query = """
query ($id: Int) {
query ($id: ID) {
blogPage(id: $id) {
id
urlPath
Expand Down

0 comments on commit 0b72e6e

Please sign in to comment.