nautobot.apps.graphql
¶
GraphQL API for Nautobot.
nautobot.apps.graphql.BigInteger
¶
Bases: BigInt
For backwards compatibility only.
nautobot.apps.graphql.ContentTypeType
¶
Bases: OptimizedNautobotObjectType
Graphene-Django object type for ContentType records.
Needed because ContentType is a built-in model, not one that we own and can auto-generate types for.
nautobot.apps.graphql.OptimizedNautobotObjectType
¶
Bases: DjangoObjectType
get_node(info, id)
classmethod
¶
Override get_node to enforce object-level permissions.
We intentionally do NOT override get_queryset (see above), so permission enforcement for Relay-style node lookups and any plugin code that calls get_node() is handled here instead.
nautobot.apps.graphql.construct_resolver(model_name, resolver_type)
¶
Constructs a resolve_[cable_peer|connected_endpoint]_
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model to construct a resolver function for (e.g. CircuitTermination). |
required |
resolver_type
|
str
|
One of ['connected_endpoint', 'cable_peer'] |
required |
nautobot.apps.graphql.execute_query(query, variables=None, request=None, user=None)
¶
Execute a query from the ORM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
String with GraphQL query. |
required |
variables
|
dict
|
If the query has variables they need to be passed in as a dictionary. |
None
|
request
|
RequestFactory
|
Used to authenticate. |
None
|
user
|
User
|
Used to authenticate. |
None
|
Returns:
| Type | Description |
|---|---|
GraphQLDocument
|
Result for query |
nautobot.apps.graphql.execute_saved_query(saved_query_name, **kwargs)
¶
Execute saved query from the ORM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
saved_query_name
|
str
|
Name of a saved GraphQL query. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
variables |
Optional[dict]
|
If the query has variables they need to be passed in as a dictionary. |
request |
Optional[RequestFactory]
|
Used to authenticate. |
user |
Optional[User]
|
Used to authenticate. |
Returns:
| Type | Description |
|---|---|
GraphQLDocument
|
Result for query |
nautobot.apps.graphql.get_filtering_args_from_filterset(filterset_class)
¶
Generate a list of filter arguments from a filterset.
The FilterSet class will be instantiated before extracting the list of arguments to account for dynamic filters, inserted when the class is instantiated. (required for Custom Fields filters).
Filter fields that are inheriting from BooleanFilter and NumberFilter will be converted to their appropriate type, everything else will be of type String. if the filter field is a subclass of MultipleChoiceFilter, the argument will be converted as a list
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filterset_class
|
FilterSet
|
FilterSet class used to extract the argument |
required |
Returns:
| Type | Description |
|---|---|
dict[Argument]
|
Filter Arguments organized in a dictionary |
nautobot.apps.graphql.str_to_var_name(verbose_name)
¶
Convert a string to a variable compatible name.
Examples:
IP Addresses > ip_addresses