Closed estyxx closed 10 months ago
@estyxx the pre-commit failure is from the recent ruff update. can you update tests/settings.py:L190
to be # noqa: S105
?
~~ Mmm it's already commented with #noqa S105 on my branch 🤔 ~~ Ah was incorrect! fixed!
Forgive me if this is an ignorant question, but why should we use ID
rather than Int
? I assume that the id
field maps to Page.id
, which is an integer column.
The benefit of using ID
over Int
everywhere is that it can support models (e.g. snippets) with non-int primary keys. Also https://graphql.com/learn/scalars-objects-lists/#the-id-type mentions lots of frameworks/tools have better support for ID
out of the box.
Now, this PR only changes it for pages, so if we commit, we should go all the way.
The reason I haven't merged this yet is that I am still deciding as it is a potentially breaking change
@zerolab I rebased this PR :)
Currently, in the Wagtail GraphQL API of wagtail-grapple, there is an inconsistency in the input types for the
pages
andpage
queries. While thepages
query expects anID
as an input, thepage
query expects anInt
. This has been leading to unnecessary conversion between string and integer.Proposed Changes
I propose to make the input types consistent by changing the
id
in thepage
query to be of typeID
(the same as in thepages
query).The change can be made in the following file: grapple/types/pages.py#L336
By changing the return type to
graphene.ID
, it ensures uniformity across the queries and eradicates the need for conversions between string and integer.I updated the documentation as well.