nautobot.apps.graphql - Nautobot Documentation

Skip to content

# `nautobot.apps.graphql`

GraphQL API for Nautobot.

## `nautobot.apps.graphql.BigInteger`

Bases: `Scalar`

An integer which, unlike GraphQL's native Int type, doesn't reject values outside (-2^31, 2^31-1).

Currently only used for ASNField, which goes up to 2^32-1 (i.e., unsigned 32-bit int); it's possible that this approach may fail for values in excess of 2^53-1 (the largest integer value supported in JavaScript).

## `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.construct_resolver(model_name, resolver_type)`

Constructs a resolve_[cable_peer|connected_endpoint]_ function for a given model type.

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