Skip to content

Add tempfile._TemporaryFileWrapper to transport file_classes #596

Closed

Description

@srittau

tempfile._TemporaryFileWrapper is the return type of the (confusingly named) function tempfile.NamedTemporaryFile. As such it's a useful class for sending files via GraphQL:

with NamedTemporaryFile as file:
    file.write(...)
    request = GraphQLRequest("...", variable_values={"file": file})
    ...

Activity

  1. leszekhanusz commented on Jun 29, 2026

    @leszekhanusz
    Collaborator

    Using a file directly in a variable is deprecated. The correct way to add a file now is to use FileVar (see documentation)

  2. added
    type: question or discussion
    on Jun 29, 2026
  3. leszekhanusz commented on Jun 29, 2026

    @leszekhanusz
    Collaborator

    I realize the documentation only shows using FileVar with a file path as a string, but you should also be able to pass an opened file directly with FileVar(file) like it in this test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: question or discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions