GraphQL query stopped working on Netbox 3.4 while was working on 3.3 #7561

Closed
opened 2025-12-29 20:25:28 +01:00 by adam · 3 comments
Owner

Originally created by @dmulyalin on GitHub (Jan 26, 2023).

NetBox version

v3.4.3

Python version

3.8

Steps to Reproduce

Run this query in GraphQL sandbox:

query 
  { 
    inventory_item_list(
      device: "fceos4", 
      component_type: "dcim.interface") {
      	name component_id
    }
  }

Expected Behavior

Above query return requested data same as it was on Netbox 3.3

Observed Behavior

Receiving error in response:

{
  "errors": [
    {
      "message": "Cannot query field 'component_id' on type 'InventoryItemType'. Did you mean 'component'?",
      "locations": [
        {
          "line": 6,
          "column": 13
        }
      ]
    }
  ]
}
Originally created by @dmulyalin on GitHub (Jan 26, 2023). ### NetBox version v3.4.3 ### Python version 3.8 ### Steps to Reproduce Run this query in GraphQL sandbox: ``` query { inventory_item_list( device: "fceos4", component_type: "dcim.interface") { name component_id } } ``` ### Expected Behavior Above query return requested data same as it was on Netbox 3.3 ### Observed Behavior Receiving error in response: ``` { "errors": [ { "message": "Cannot query field 'component_id' on type 'InventoryItemType'. Did you mean 'component'?", "locations": [ { "line": 6, "column": 13 } ] } ] } ```
adam added the type: bug label 2025-12-29 20:25:28 +01:00
adam closed this issue 2025-12-29 20:25:28 +01:00
Author
Owner

@dmulyalin commented on GitHub (Jan 26, 2023):

If its of any use, this is the screen capture demonstrating the issue:
image

if this behavior is expected for Netbox 3.4, I would like to retrieve the ID of component to which inventory item belongs, would appreciate if anybody can advise on how to do it.

@dmulyalin commented on GitHub (Jan 26, 2023): If its of any use, this is the screen capture demonstrating the issue: ![image](https://user-images.githubusercontent.com/28857266/214827281-8ab3af21-4172-4c77-8a6d-fbaea3f4517c.png) if this behavior is expected for Netbox 3.4, I would like to retrieve the ID of component to which inventory item belongs, would appreciate if anybody can advise on how to do it.
Author
Owner

@arthanson commented on GitHub (Jan 26, 2023):

@dmulyalin It's actually returning the component list now which can be queried using inline fragments (https://www.apollographql.com/docs/kotlin/v2/essentials/inline-fragments/), so something like the below should work. Add the appropriate "... on " as needed (FrontPortType, RearPortType, InterfaceType, PowerPortType, ConsolePortType, PowerOutletType, ConsoleServerPortType):

query 
  { 
    inventory_item_list(
      device: "fceos4", 
      component_type: "dcim.interface") {
        name
        component {
          ... on RearPortType {
            id
          }
        }
    }
  }  
@arthanson commented on GitHub (Jan 26, 2023): @dmulyalin It's actually returning the component list now which can be queried using inline fragments (https://www.apollographql.com/docs/kotlin/v2/essentials/inline-fragments/), so something like the below should work. Add the appropriate "... on " as needed (FrontPortType, RearPortType, InterfaceType, PowerPortType, ConsolePortType, PowerOutletType, ConsoleServerPortType): ``` query { inventory_item_list( device: "fceos4", component_type: "dcim.interface") { name component { ... on RearPortType { id } } } } ```
Author
Owner

@dmulyalin commented on GitHub (Jan 27, 2023):

@arthanson ok, ic, thank you for clarifications, will give it a try.

@dmulyalin commented on GitHub (Jan 27, 2023): @arthanson ok, ic, thank you for clarifications, will give it a try.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7561