mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Introduce is_graphql_request() utility function
This commit is contained in:
parent
f3155973f6
commit
55e1929744
@ -23,6 +23,7 @@ __all__ = (
|
||||
'get_serializer_for_model',
|
||||
'get_view_name',
|
||||
'is_api_request',
|
||||
'is_graphql_request',
|
||||
)
|
||||
|
||||
|
||||
@ -60,6 +61,13 @@ def is_api_request(request):
|
||||
return request.path_info.startswith(api_path) and request.content_type == HTTP_CONTENT_TYPE_JSON
|
||||
|
||||
|
||||
def is_graphql_request(request):
|
||||
"""
|
||||
Return True of the request is being made via the GraphQL API.
|
||||
"""
|
||||
return request.path_info == reverse('graphql') and request.content_type == HTTP_CONTENT_TYPE_JSON
|
||||
|
||||
|
||||
def get_view_name(view):
|
||||
"""
|
||||
Derive the view name from its associated model, if it has one. Fall back to DRF's built-in `get_view_name()`.
|
||||
|
Loading…
Reference in New Issue
Block a user