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

deepcopy fails if the schema has a directive with an enum argument #210

Closed
menma1234 opened this issue Nov 2, 2023 · 1 comment
Closed

Comments

@menma1234
Copy link

It seems like if you have a GraphQLSchema containing a directive definition that has an argument that is an enum, trying to deepcopy it results in a TypeError:

Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from copy import deepcopy
>>> from graphql import build_schema
>>> schema_text = """
... directive @testDirective(enumArg: TestEnum) on FIELD_DEFINITION
...
... enum TestEnum {
...     FIRST
...     SECOND
... }
...
... type TestType {
...     field: String @testDirective(enumArg: FIRST)
... }
... """
>>> schema = build_schema(schema_text)
>>> deepcopy(schema)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python310\lib\copy.py", line 153, in deepcopy
    y = copier(memo)
  File "C:\test\.venv\lib\site-packages\graphql\type\schema.py", line 329, in __deepcopy__
    return self.__class__(
  File "C:\test\.venv\lib\site-packages\graphql\type\schema.py", line 258, in __init__
    raise TypeError(
TypeError: Schema must contain uniquely named types but contains multiple types named 'TestEnum'.

Using graphql-core version 3.2.3.

@Cito
Copy link
Member

Cito commented Jan 26, 2025

This is now fixed in v3.3.0a7 and v3.2.6.

@Cito Cito closed this as completed Jan 26, 2025
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

No branches or pull requests

2 participants