Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Expose record_type for responses in graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Jan 31, 2022
1 parent 0b9aa0e commit f1b8c61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ert_storage/graphql/responses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List, Optional, TYPE_CHECKING
from enum import Enum
from typing import Any, List, Optional, TYPE_CHECKING
import graphene as gr

from ert_storage.ext.graphene_sqlalchemy import SQLAlchemyObjectType
Expand All @@ -14,6 +15,10 @@ class Meta:
model = ds.Record

name = gr.String()
record_type = gr.Enum.from_enum(ds.RecordType)

def resolve_name(root: ds.Record, info: "ResolveInfo") -> str:
return root.name

def resolve_record_type(root: ds.Record, info: "ResolveInfo") -> Enum:
return root.record_info.record_type
2 changes: 2 additions & 0 deletions tests/integration/gql/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ensemble(id: $id) {
uniqueResponses {
name
recordType
}
}
}
Expand Down Expand Up @@ -73,6 +74,7 @@ def test_get_gql_response(client, create_experiment, create_ensemble):
r = client.gql_execute(GET_UNIQUE_RESPONSES, variable_values={"id": ensemble_id})
for response in r["data"]["ensemble"]["uniqueResponses"]:
assert response["name"] in RESPONSE_NAMES
assert response["recordType"] == "F64_MATRIX"

# retrieve all responses and realizations
r = client.gql_execute(GET_ALL_RESPONSES, variable_values={"id": ensemble_id})
Expand Down

0 comments on commit f1b8c61

Please sign in to comment.