Repository: nautobot/nautobot

Issue:
Plugin development docs for GraphQL should warn about decorator with explicit object types
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Python version: any
* Nautobot version: 1.0.1

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. In a plugin, add automatic GraphQL support to the data models using `@extras_features("graphql")` decorator.
2. Later, realize you need to explicitly define a GraphQL object type for your models, so do so. Do not remove the decorator from the model class.

<!-- What did you expect to happen? -->
### Expected Behavior

Either:
1) The explicitly defined model object type should take precedence over the auto-generated object type, or
2) Nautobot should log a warning or error about the conflict between the two object types.

In either case, it would be good for the plugin development guide to explicitly warn about not using the decorator in combination with explicitly defined object types.

<!-- What happened instead? -->
### Observed Behavior

The autogenerated object type is used, and the explicitly defined model object type is silently ignored.


Discussion:

Resolving patch:
diff --git a/nautobot/core/graphql/schema.py b/nautobot/core/graphql/schema.py
--- a/nautobot/core/graphql/schema.py
+++ b/nautobot/core/graphql/schema.py
@@ -312,7 +312,14 @@ def already_present(model):
         model = schema_type._meta.model
         type_identifier = f"{model._meta.app_label}.{model._meta.model_name}"
 
-        if type_identifier not in registry["graphql_types"].keys():
+        if type_identifier in registry["graphql_types"]:
+            logger.warning(
+                f'Unable to load schema type for the model "{type_identifier}" as there is already another type '
+                "registered under this name. If you are seeing this message during plugin development, check to "
+                "make sure that you aren't using @extras_features(\"graphql\") on the same model you're also "
+                "defining a custom GraphQL type for."
+            )
+        else:
             registry["graphql_types"][type_identifier] = schema_type
 
     # Extend schema_type with dynamic attributes for all object defined in the registry


Test patch: