prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  GraphQL returns all objects if tag doesn't exist
  ### NetBox version
  
  v3.4.2
  
  ### Python version
  
  3.10
  
  ### Steps to Reproduce
  
  1. query GraphQL for device/interface with a tag that doesn't exist
  
  ### Expected Behavior
  
  Resulting list of devices/interfaces only contains devices matching the tags or none if no device exists with matching tags.
  
  ### Observed Behavior
  
  All devices/interfaces are returned no matter what tag filter has been applied. Same seems to apply for all kinds of filters that can be defined in GraphQL. No errors are returned.
  
  Example below
  
  query:
  `{
    device_list(tag: "blablalba") {
      id
      name
      tags {
        name
      }
    }
      interface_list(tag: "not-ipmi_exporter") {
      id
      device {
        id
      }
       tags {
        name
      }
    }
  }
  `
  
  result:
  `{
    "data": {
      "device_list": [
        {
          "id": "1",
          "name": "device-A",
          "tags": [
            {
              "name": "node_exporter"
            }
          ]
        },
        {
          "id": "2",
          "name": "device-B",
          "tags": [
            {
              "name": "node_exporter"
            }
          ]
        }
      ],
      "interface_list": [
        {
          "id": "1",
          "device": {
            "id": "1"
          },
          "tags": [
            {
              "name": "ipmi_exporter"
            }
          ]
        },
        {
          "id": "2",
          "device": {
            "id": "2"
          },
          "tags": [
            {
              "name": "ipmi_exporter"
            }
          ]
        }
      ]
    }
  }`
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `netbox/netbox/graphql/fields.py`
  Content:
  ```
  1 from functools import partial
  2 
  3 import graphene
  4 from graphene_django import DjangoListField
  5 
  6 from .utils import get_graphene_type
  7 
  8 __all__ = (
  9     'ObjectField',
  10     'ObjectListField',
  11 )
  12 
  13 
  14 class ObjectField(graphene.Field):
  15     """
  16     Retrieve a single object, identified by its numeric ID.
  17     """
  18     def __init__(self, *args, **kwargs):
  19 
  20         if 'id' not in kwargs:
  21             kwargs['id'] = graphene.Int(required=True)
  22 
  23         super().__init__(*args, **kwargs)
  24 
  25     @staticmethod
  26     def object_resolver(django_object_type, root, info, **args):
  27         """
  28         Return an object given its numeric ID.
  29         """
  30         manager = django_object_type._meta.model._default_manager
  31         queryset = django_object_type.get_queryset(manager, info)
  32 
  33         return queryset.get(**args)
  34 
  35     def get_resolver(self, parent_resolver):
  36         return partial(self.object_resolver, self._type)
  37 
  38 
  39 class ObjectListField(DjangoListField):
  40     """
  41     Retrieve a list of objects, optionally filtered by one or more FilterSet filters.
  42     """
  43     def __init__(self, _type, *args, **kwargs):
  44         filter_kwargs = {}
  45 
  46         # Get FilterSet kwargs
  47         filterset_class = getattr(_type._meta, 'filterset_class', None)
  48         if filterset_class:
  49             for filter_name, filter_field in filterset_class.get_filters().items():
  50                 field_type = get_graphene_type(type(filter_field))
  51                 filter_kwargs[filter_name] = graphene.Argument(field_type)
  52 
  53         super().__init__(_type, args=filter_kwargs, *args, **kwargs)
  54 
  55     @staticmethod
  56     def list_resolver(django_object_type, resolver, default_manager, root, info, **args):
  57         queryset = super(ObjectListField, ObjectListField).list_resolver(django_object_type, resolver, default_manager, root, info, **args)
  58 
  59         # Instantiate and apply the FilterSet, if defined
  60         filterset_class = django_object_type._meta.filterset_class
  61         if filterset_class:
  62             filterset = filterset_class(data=args, queryset=queryset, request=info.context)
  63             return filterset.qs
  64 
  65         return queryset
  66
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/netbox/netbox/graphql/fields.py b/netbox/netbox/graphql/fields.py
  --- a/netbox/netbox/graphql/fields.py
  +++ b/netbox/netbox/graphql/fields.py
  @@ -60,6 +60,8 @@
           filterset_class = django_object_type._meta.filterset_class
           if filterset_class:
               filterset = filterset_class(data=args, queryset=queryset, request=info.context)
  +            if not filterset.is_valid():
  +                return queryset.none()
               return filterset.qs
   
           return queryset
  
verification_info: {"golden_diff": "diff --git a/netbox/netbox/graphql/fields.py b/netbox/netbox/graphql/fields.py\n--- a/netbox/netbox/graphql/fields.py\n+++ b/netbox/netbox/graphql/fields.py\n@@ -60,6 +60,8 @@\n         filterset_class = django_object_type._meta.filterset_class\n         if filterset_class:\n             filterset = filterset_class(data=args, queryset=queryset, request=info.context)\n+            if not filterset.is_valid():\n+                return queryset.none()\n             return filterset.qs\n \n         return queryset\n", "issue": "GraphQL returns all objects if tag doesn't exist\n### NetBox version\n\nv3.4.2\n\n### Python version\n\n3.10\n\n### Steps to Reproduce\n\n1. query GraphQL for device/interface with a tag that doesn't exist\n\n### Expected Behavior\n\nResulting list of devices/interfaces only contains devices matching the tags or none if no device exists with matching tags.\n\n### Observed Behavior\n\nAll devices/interfaces are returned no matter what tag filter has been applied. Same seems to apply for all kinds of filters that can be defined in GraphQL. No errors are returned.\r\n\r\nExample below\r\n\r\nquery:\r\n`{\r\n  device_list(tag: \"blablalba\") {\r\n    id\r\n    name\r\n    tags {\r\n      name\r\n    }\r\n  }\r\n    interface_list(tag: \"not-ipmi_exporter\") {\r\n    id\r\n    device {\r\n      id\r\n    }\r\n     tags {\r\n      name\r\n    }\r\n  }\r\n}\r\n`\r\n\r\nresult:\r\n`{\r\n  \"data\": {\r\n    \"device_list\": [\r\n      {\r\n        \"id\": \"1\",\r\n        \"name\": \"device-A\",\r\n        \"tags\": [\r\n          {\r\n            \"name\": \"node_exporter\"\r\n          }\r\n        ]\r\n      },\r\n      {\r\n        \"id\": \"2\",\r\n        \"name\": \"device-B\",\r\n        \"tags\": [\r\n          {\r\n            \"name\": \"node_exporter\"\r\n          }\r\n        ]\r\n      }\r\n    ],\r\n    \"interface_list\": [\r\n      {\r\n        \"id\": \"1\",\r\n        \"device\": {\r\n          \"id\": \"1\"\r\n        },\r\n        \"tags\": [\r\n          {\r\n            \"name\": \"ipmi_exporter\"\r\n          }\r\n        ]\r\n      },\r\n      {\r\n        \"id\": \"2\",\r\n        \"device\": {\r\n          \"id\": \"2\"\r\n        },\r\n        \"tags\": [\r\n          {\r\n            \"name\": \"ipmi_exporter\"\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}`\n", "before_files": [{"content": "from functools import partial\n\nimport graphene\nfrom graphene_django import DjangoListField\n\nfrom .utils import get_graphene_type\n\n__all__ = (\n    'ObjectField',\n    'ObjectListField',\n)\n\n\nclass ObjectField(graphene.Field):\n    \"\"\"\n    Retrieve a single object, identified by its numeric ID.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n\n        if 'id' not in kwargs:\n            kwargs['id'] = graphene.Int(required=True)\n\n        super().__init__(*args, **kwargs)\n\n    @staticmethod\n    def object_resolver(django_object_type, root, info, **args):\n        \"\"\"\n        Return an object given its numeric ID.\n        \"\"\"\n        manager = django_object_type._meta.model._default_manager\n        queryset = django_object_type.get_queryset(manager, info)\n\n        return queryset.get(**args)\n\n    def get_resolver(self, parent_resolver):\n        return partial(self.object_resolver, self._type)\n\n\nclass ObjectListField(DjangoListField):\n    \"\"\"\n    Retrieve a list of objects, optionally filtered by one or more FilterSet filters.\n    \"\"\"\n    def __init__(self, _type, *args, **kwargs):\n        filter_kwargs = {}\n\n        # Get FilterSet kwargs\n        filterset_class = getattr(_type._meta, 'filterset_class', None)\n        if filterset_class:\n            for filter_name, filter_field in filterset_class.get_filters().items():\n                field_type = get_graphene_type(type(filter_field))\n                filter_kwargs[filter_name] = graphene.Argument(field_type)\n\n        super().__init__(_type, args=filter_kwargs, *args, **kwargs)\n\n    @staticmethod\n    def list_resolver(django_object_type, resolver, default_manager, root, info, **args):\n        queryset = super(ObjectListField, ObjectListField).list_resolver(django_object_type, resolver, default_manager, root, info, **args)\n\n        # Instantiate and apply the FilterSet, if defined\n        filterset_class = django_object_type._meta.filterset_class\n        if filterset_class:\n            filterset = filterset_class(data=args, queryset=queryset, request=info.context)\n            return filterset.qs\n\n        return queryset\n", "path": "netbox/netbox/graphql/fields.py"}], "after_files": [{"content": "from functools import partial\n\nimport graphene\nfrom graphene_django import DjangoListField\n\nfrom .utils import get_graphene_type\n\n__all__ = (\n    'ObjectField',\n    'ObjectListField',\n)\n\n\nclass ObjectField(graphene.Field):\n    \"\"\"\n    Retrieve a single object, identified by its numeric ID.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n\n        if 'id' not in kwargs:\n            kwargs['id'] = graphene.Int(required=True)\n\n        super().__init__(*args, **kwargs)\n\n    @staticmethod\n    def object_resolver(django_object_type, root, info, **args):\n        \"\"\"\n        Return an object given its numeric ID.\n        \"\"\"\n        manager = django_object_type._meta.model._default_manager\n        queryset = django_object_type.get_queryset(manager, info)\n\n        return queryset.get(**args)\n\n    def get_resolver(self, parent_resolver):\n        return partial(self.object_resolver, self._type)\n\n\nclass ObjectListField(DjangoListField):\n    \"\"\"\n    Retrieve a list of objects, optionally filtered by one or more FilterSet filters.\n    \"\"\"\n    def __init__(self, _type, *args, **kwargs):\n        filter_kwargs = {}\n\n        # Get FilterSet kwargs\n        filterset_class = getattr(_type._meta, 'filterset_class', None)\n        if filterset_class:\n            for filter_name, filter_field in filterset_class.get_filters().items():\n                field_type = get_graphene_type(type(filter_field))\n                filter_kwargs[filter_name] = graphene.Argument(field_type)\n\n        super().__init__(_type, args=filter_kwargs, *args, **kwargs)\n\n    @staticmethod\n    def list_resolver(django_object_type, resolver, default_manager, root, info, **args):\n        queryset = super(ObjectListField, ObjectListField).list_resolver(django_object_type, resolver, default_manager, root, info, **args)\n\n        # Instantiate and apply the FilterSet, if defined\n        filterset_class = django_object_type._meta.filterset_class\n        if filterset_class:\n            filterset = filterset_class(data=args, queryset=queryset, request=info.context)\n            if not filterset.is_valid():\n                return queryset.none()\n            return filterset.qs\n\n        return queryset\n", "path": "netbox/netbox/graphql/fields.py"}]}