GNS-Science / nshm-toshi-api

An extensible API where task metadata, and important input and output files relating to data-intensive science processes are retained. Custom task schemas can be defined to support their meta-data needs.
GNU Affero General Public License v3.0
0 stars 0 forks source link

Fix: Inversion Solution source solutions incorrect type #214

Closed benjamineac closed 4 months ago

benjamineac commented 5 months ago

Inversion solution's source solution field always returning an InversionSolution - even if Time Dependent or Aggregate

benjamineac commented 5 months ago

query InversionSolutionQuery( $id: ID! ) { node(id: $id) { __typename ... on InversionSolution { id file_name file_url file_size mfd_table_id hazard_table_id created md5_digest produced_by { __typename ... on Node { __isNode: __typename id } } meta { k v } tables { table_id table_type created } } ... on InversionSolutionNrml { id file_name created file_size md5_digest file_url meta { k v } source_solution { __typename ... on Node { __isNode: __typename id } ... on InversionSolution { created } } relations { total_count } } ... on ScaledInversionSolution { id file_name created file_size md5_digest file_url produced_by { __typename ... on Node { __isNode: __typename id } } meta { k v } source_solution { ... on Node { __isNode: __typename id } created produced_by { __typename ... on Node { __isNode: __typename id } } id } relations { total_count } tables { table_id table_type created } } ... on TimeDependentInversionSolution { id file_name created file_size md5_digest file_url produced_by { __typename ... on Node { __isNode: __typename id } } meta { k v } source_solution { ... on Node { __isNode: __typename id } created id } relations { total_count } tables { table_id table_type created } } ... on AggregateInversionSolution { id file_name created file_size md5_digest file_url meta { k v } produced_by { __typename ... on Node { __isNode: __typename id } } source_solutions { __typename ... on Node { __isNode: __typename id } ... on InversionSolution { created } } relations { total_count } tables { table_id table_type created } } id } }

{ "variables": { "id": "U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTIwODM3" } }

source solution returned: SW52ZXJzaW9uU29sdXRpb246MTE5MTY0 correct source solution: VGltZURlcGVuZGVudEludmVyc2lvblNvbHV0aW9uOjExOTE2NA==

chrisbc commented 5 months ago

So @benjamineac I think you're right, that the issue is occurring in the stitched APIGW and not in the underlying TOSHI API. Not quite sure how yet. FYI @chrisdicaprio

However, I think that the TOSHI API behaviour may actually be illegal, asking for node of type Y should probably never return a node of type Z. I'll look into why we're doing this ...it might have been a dirty hack to get things moving way back when.

test query:

query B {
  node(id:"SW52ZXJzaW9uU29sdXRpb246MTEzNTE4") {
    __typename
       id
    ...on InversionSolution {
      __typename
      id
    }
  }
}

from APIGW (Stitched) @ https://nshm-api-test.gns.cri.nz/weka-app-api/graphql? we get ....

{
  "data": {
    "node": {
      "__typename": "InversionSolution",
      "id": "SW52ZXJzaW9uU29sdXRpb246MTEzNTE4"
    }
  }
}

and from toshi api @ https://aihssdkef5.execute-api.ap-southeast-2.amazonaws.com/prod/graphql we get

{
  "data": {
    "node": {
      "__typename": "AggregateInversionSolution",
      "id": "QWdncmVnYXRlSW52ZXJzaW9uU29sdXRpb246MTEzNTE4",
      "source_solutions": [
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMjU5"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzQ5"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzAx"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMjkz"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzE2"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzQ3"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzQ0"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzUz"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzgw"
        },
        {
          "__typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTEzMzgz"
        }
      ]
    }
  }
}
chrisbc commented 4 months ago

new version of your first query working in toshi-api deploy test....

query InversionSolutionQuery($id: ID!) {
  node(id: $id) {
    __typename
    ... on InversionSolution {
      id
      file_name
      file_url
      file_size
      mfd_table_id
      hazard_table_id
      created
      md5_digest
      produced_by {
        __typename
        ... on Node {
          __isNode: __typename
          id
        }
      }
      meta {
        k
        v
      }
      tables {
        table_id
        table_type
        created
      }
    }
    ... on InversionSolutionNrml {
      id
      file_name
      created
      file_size
      md5_digest
      file_url
      meta {
        k
        v
      }
      source_solution {
        __typename
        ... on Node {
          __isNode: __typename
          id
        }
        ... on InversionSolution {
          created
        }
      }
      relations {
        total_count
      }
    }
    ... on ScaledInversionSolution {
      id
      file_name
      created
      file_size
      md5_digest
      file_url
      produced_by {
        __typename
        ... on Node {
          __isNode: __typename
          id
        }
      }
      meta {
        k
        v
      }
      source_solution {
        ... on Node {
          __isNode: __typename
          id
        }
        ... on InversionSolutionInterface {
          created
          produced_by {
            __typename
            ... on Node {
              __isNode: __typename
              id
            }
          }
        }
      }
      relations {
        total_count
      }
      tables {
        table_id
        table_type
        created
      }
    }
    ... on TimeDependentInversionSolution {
      id
      file_name
      created
      file_size
      md5_digest
      file_url
      produced_by {
        __typename
        ... on Node {
          __isNode: __typename
          id
        }
      }
      meta {
        k
        v
      }
      source_solution {
        ... on Node {
          __isNode: __typename
          id
        }
        created
        id
      }
      relations {
        total_count
      }
      tables {
        table_id
        table_type
        created
      }
    }
    ... on AggregateInversionSolution {
      id
      file_name
      created
      file_size
      md5_digest
      file_url
      meta {
        k
        v
      }
      produced_by {
        __typename
        ... on Node {
          __isNode: __typename
          id
        }
      }
      source_solutions {
        __typename
        ... on Node {
          __isNode: __typename
          id
        }
        ... on InversionSolution {
          created
        }
      }
      relations {
        total_count
      }
      tables {
        table_id
        table_type
        created
      }
    }
  }
}
chrisbc commented 4 months ago

closed by #215