diff --git a/docs/general-usage/graphql-types.rst b/docs/general-usage/graphql-types.rst index 4497b91f..51c9fba5 100644 --- a/docs/general-usage/graphql-types.rst +++ b/docs/general-usage/graphql-types.rst @@ -80,7 +80,7 @@ The singular ``page`` field accepts the following arguments: .. code-block:: graphql - id: Int # Can be used on it's own + id: ID # Can be used on it's own slug: String # Can be used on it's own urlPath: String # Can be used on it's own token: String # Must be used with one of the others. Usually contentType diff --git a/grapple/helpers.py b/grapple/helpers.py index 85c30404..fdd6d813 100644 --- a/grapple/helpers.py +++ b/grapple/helpers.py @@ -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( @@ -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( diff --git a/grapple/types/pages.py b/grapple/types/pages.py index 70c6248f..e324cd66 100644 --- a/grapple/types/pages.py +++ b/grapple/types/pages.py @@ -334,7 +334,7 @@ class Mixin: ) page = graphene.Field( PageInterface, - id=graphene.Int(), + id=graphene.ID(), slug=graphene.String(), url_path=graphene.Argument( graphene.String, diff --git a/grapple/types/sites.py b/grapple/types/sites.py index 908f81c0..fe0ab95e 100644 --- a/grapple/types/sites.py +++ b/grapple/types/sites.py @@ -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(), diff --git a/tests/test_blog.py b/tests/test_blog.py index e6914d41..c38ea78a 100644 --- a/tests/test_blog.py +++ b/tests/test_blog.py @@ -136,7 +136,7 @@ def setUp(self): def test_blog_page(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { title @@ -151,7 +151,7 @@ def test_blog_page(self): def test_related_author_page(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { author { @@ -171,7 +171,7 @@ def test_related_author_page(self): def get_blocks_from_body(self, block_type, block_query="rawValue", page_id=None): query = f""" - query($id: Int) {{ + query($id: ID) {{ page(id: $id) {{ ... on BlogPage {{ body {{ @@ -248,7 +248,7 @@ def test_streamfield_richtextblock(self): def test_richtext(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { summary @@ -471,7 +471,7 @@ def test_blog_body_objectives(self): def test_blog_embed(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { body { @@ -656,7 +656,7 @@ def test_blog_body_snippetchooserblock_person(self): # Next 2 tests are used to test the Collection API, both ForeignKey and nested field extraction. def test_blog_page_related_links(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { relatedLinks { @@ -676,7 +676,7 @@ def test_blog_page_related_links(self): def test_blog_page_related_urls(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { relatedUrls @@ -696,7 +696,7 @@ def test_blog_page_paginated_authors(self): per_page = 5 query = """ - query ($id: Int, $page: PositiveInt, $perPage: PositiveInt) { + query ($id: ID, $page: PositiveInt, $perPage: PositiveInt) { page(id: $id) { ... on BlogPage { paginatedAuthors(page: $page, perPage: $perPage) { @@ -905,7 +905,7 @@ def test_singular_blog_page_query(self): def test_blog_page_tags(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { tags { @@ -1057,7 +1057,7 @@ def test_graphqlfield_method_with_extra_arg_in_structblock(self): def test_custom_property(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { ... on BlogPage { customProperty diff --git a/tests/test_general.py b/tests/test_general.py index 0bfe2a87..cc229264 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -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 @@ -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 } @@ -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 @@ -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 @@ -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 diff --git a/tests/test_grapple.py b/tests/test_grapple.py index 40894d15..098ea3f9 100644 --- a/tests/test_grapple.py +++ b/tests/test_grapple.py @@ -352,7 +352,7 @@ def test_pages_content_type_filter(self): def test_page(self): query = """ - query($id: Int) { + query($id: ID) { page(id: $id) { contentType parent {