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

graphene upgrade from v2 to v3 breaks to_global_id node function #1575

Closed
DrJfrost opened this issue Aug 28, 2024 · 1 comment
Closed

graphene upgrade from v2 to v3 breaks to_global_id node function #1575

DrJfrost opened this issue Aug 28, 2024 · 1 comment
Labels

Comments

@DrJfrost
Copy link

DrJfrost commented Aug 28, 2024

Note:` for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • What is the current behavior?

the following implementation of to_global_id fails after upgrading graphene to v3

from graphene import (
    Field,
    String,
    Int,
    ObjectType,
    relay,
    ID,
    List,
    NonNull,
    Date,
    Boolean,
)

from graphene.relay.node import to_global_id


class SubmittedContent(ObjectType):

    global_id = ID(description="The global ID of the submitted content.")
    db_id = Int()
    name = String(description="The name of the submitted content.")
    type = String(description="The type of the submitted content.")
    submitted_by = String(description="The name of the user who submitted the content.")
    status = String(description="The status of the submitted content.")

    def resolve_global_id(root, info):

        if root.get("type") in [
            DocumentTypes.FORM_RESULT.value,
            DocumentTypes.SITE_DIARY.value,
            DocumentTypes.DIGITAL_DOCKET.value,
            DocumentTypes.TIMESHEET.value,
        ]:
            doc_type = root.get("type")
            if DocumentTypes(doc_type) == DocumentTypes.SITE_DIARY:
                doc_type = "SiteDiary"
            return to_global_id(root.get("type"), root["db_id"])
        return None

this ends up in

cannot import name 'to_global_id' from 'graphene.relay.node'

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
    a github repo, https://repl.it or similar.

  • What is the expected behavior?

    The to_global_id function should serialize the global id

  • What is the motivation / use case for changing the behavior?
    Many people uses the relay framework and plan to upgrade from v2 to v3, there is no documantation on this breaking changes

  • Please tell us about your environment:

    • Version: 2.16.0 --> 3.0.0
    • Platform: python 3.9.5
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

    As a work around changing the imports fixes the problem.

from graphql_relay import to_global_id
@erikwrede
Copy link
Member

Hey, thanks for the report. I'm closing this, as this was one of the intended breaking changes between v2 and v3.

@erikwrede erikwrede closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants