Skip to content

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

@menma1234

Description

@menma1234

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:

Python3.10.5 (tags/v3.10.5:f377153, Jun62022, 16:14:13) [MSCv.192964bit (AMD64)] onwin32Type"help", "copyright", "credits"or"license"formoreinformation. >>>fromcopyimportdeepcopy>>>fromgraphqlimportbuild_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 (mostrecentcalllast): File"<stdin>", line1, in<module>File"C:\Program Files\Python310\lib\copy.py", line153, indeepcopyy=copier(memo) File"C:\test\.venv\lib\site-packages\graphql\type\schema.py", line329, in__deepcopy__returnself.__class__( File"C:\test\.venv\lib\site-packages\graphql\type\schema.py", line258, in__init__raiseTypeError( TypeError: Schemamustcontainuniquelynamedtypesbutcontainsmultipletypesnamed'TestEnum'.

Using graphql-core version 3.2.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions