Skip to content

Commit

Permalink
- ensure there are interfaces before checking their keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Jan 11, 2023
1 parent bf3b575 commit 2401715
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Utils/QueryAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,15 @@ public function set_list_types( ?Schema $schema, ?string $query ): array {
// if the type is a list and the named type doesn't start
// with a double __, then it should be tracked
if ( $is_list_type && 0 !== strpos( $named_type, '__' ) ) {

// if the type doesn't apply the node interface
if ( array_key_exists( 'Node', $named_type->getInterfaces() ) ) {
if ( ! empty( $named_type->getInterfaces() ) && array_key_exists( 'Node', $named_type->getInterfaces() ) ) {
// if the Type is not a Node, and has a "node" field,
// lets get the named type of the node, not the edge
$type_map[] = 'list:' . strtolower( $named_type );
} elseif ( in_array( 'node', $named_type->getFieldNames(), true ) ) {
$named_type = $named_type->getField( 'node' )->getType();
$type_map[] = 'list:' . strtolower( $named_type );
}
}
}
}

Expand All @@ -372,7 +371,7 @@ public function set_list_types( ?Schema $schema, ?string $query ): array {
// if the type is a list, store it
if ( $is_list_type && 0 !== strpos( $possible_type, '__' ) ) {
// if the type doesn't apply the node interface
if ( array_key_exists( 'Node', $possible_type->getInterfaces() ) ) {
if ( ! empty( $possible_type->getInterfaces() ) && array_key_exists( 'Node', $possible_type->getInterfaces() ) ) {
// if the Type is not a Node, and has a "node" field,
// lets get the named type of the node, not the edge
$type_map[] = 'list:' . strtolower( $possible_type );
Expand Down

0 comments on commit 2401715

Please sign in to comment.