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

fix: Remove GlobalID type from relay schema. #3180

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dusty-phillips
Copy link

@dusty-phillips dusty-phillips commented Oct 30, 2023

Description

Having this type in the schema violates the relay spec:

https://graphql.org/learn/global-object-identification/
https://relay.dev/docs/guides/graphql-server-specification/#schema

The GlobalID is technically a specialization of the existing strawberry.ID type, and the schema name should be "ID". However, we still want the ability to extract the type and internal ID from the GlobalID.

I don't really think this is the "correct" solution, but I wanted to put it up in case it helps with the discussion I started here: #3177

I am open to discussion/suggestion if this is "close" to how @patrick91 wants to do it; otherwise happy to close it without merging once your more correct solution comes out.

This is a breaking change, as anyone who is relying on GlobalID in their relay schema is going to be affected, especially on client code.

The lint error that arises is exactly what I was afraid of and I'm not clear how to resolve it.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (But I'm not sure it's accurate.)
  • I have read the CONTRIBUTING document.
  • I have updated tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage (I really want to emphasize that part; I'm not very confident in my testing so far.)).

@botberry
Copy link
Member

botberry commented Oct 30, 2023

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

Release type: patch

Description of the changes, ideally with some examples, if adding a new feature.

Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :)

Here's the tweet text:

🆕 Release (next) is out! Thanks to Dusty Phillips for the PR 👏

Get it here 👉 https://beta.strawberry.rocks/release/(next)

1 similar comment
@botberry
Copy link
Member

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

Release type: patch

Description of the changes, ideally with some examples, if adding a new feature.

Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :)

Here's the tweet text:

🆕 Release (next) is out! Thanks to Dusty Phillips for the PR 👏

Get it here 👉 https://beta.strawberry.rocks/release/(next)

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #3180 (6e048d0) into main (74eb27e) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3180   +/-   ##
=======================================
  Coverage   96.53%   96.53%           
=======================================
  Files         484      484           
  Lines       29812    29814    +2     
  Branches     3680     3680           
=======================================
+ Hits        28780    28782    +2     
  Misses        849      849           
  Partials      183      183           

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 30, 2023

CodSpeed Performance Report

Merging #3180 will not alter performance

Comparing dusty-phillips:dustyphillips/no-global-id-in-schema (6e048d0) with main (af39ae6)

Summary

✅ 11 untouched benchmarks

Having this type in the schema violates the relay spec.
The GlobalID is technically an interpretation of the ID type,
and the schema should always return ID for that.

I created a new scalar type called ID. It's unclear how this
collides with the strawberry.ID, but given that strawberry.ID
isn't actually a scalar type, I am hoping it is ok.
@dusty-phillips dusty-phillips force-pushed the dustyphillips/no-global-id-in-schema branch from 3a4213e to 63594fe Compare October 30, 2023 15:14
@patrick91 patrick91 requested a review from bellini666 May 29, 2024 10:51
@bellini666
Copy link
Member

This is something that a lot of users already asked for: a way to have the scalar named ID instead of GlobalID

There're just 2 issues that I see with this PR:

  1. It is a "breaking change" in the API, which makes me worried. Maybe we should do it either way and add a huge BREAKING CHANGE notice in the release notes, but @patrick91 might prefer this to be done differently?

  2. What to do with users that use both? Like, in your schema if you use both relay.ID and strawberry.ID` it will raise issues because you are using different scalars with the same name

@patrick91
Copy link
Member

This is something that a lot of users already asked for: a way to have the scalar named ID instead of GlobalID

There're just 2 issues that I see with this PR:

  1. It is a "breaking change" in the API, which makes me worried. Maybe we should do it either way and add a huge BREAKING CHANGE notice in the release notes, but @patrick91 might prefer this to be done differently?

Could we make it configurable somehow? It might be painful to maintain though, but at least it gives people more time to upgrade

  1. What to do with users that use both? Like, in your schema if you use both relay.ID and strawberry.ID` it will raise issues because you are using different scalars with the same name

We could throw an error? or make relay.ID an alias?

@DoctorJohn
Copy link
Member

Could we make it configurable somehow?

users could do the reverse of this comment (#3551 (comment)) to rename relay.ID back to GloabalID until they find time to properly migrate.

We could throw an error?

I think we should. Using both scalars is violating the relay specs anyways

@aryaniyaps
Copy link
Contributor

+1. I think this should be merged soon! :)

@bellini666
Copy link
Member

I think a file inside docs/breaking-changes and also a note in the release itself should be enough to workaround the breaking change

Mostly, we need to make sure that the users know that:

GlobalID will start to be exposed as ID in the schema. It will still behave the same, it is just a change in the name inside the schema itself.

Also add an example on how to expose it as GlobalID back for anyone relying on that (I don't think almost anymore will be, unless they are using it together with ID itself)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants