Hi everyone, I am wondering if it is possible to g...
# ask-community
n
Hi everyone, I am wondering if it is possible to get return an output from a job and retrieve i from the Graphql API ?
c
Hi nourreddine. One way that you could do this is by attaching your output value as metadata: https://docs.dagster.io/concepts/ops-jobs-graphs/op-events#attaching-metadata-to-outputs Then you can write a query like this:
Copy code
query RunLogsQuery($runId: ID!) {
  logsForRun(runId: $runId) {
    ... on EventConnection {
        events {
          __typename
          ... on ExecutionStepOutputEvent {
            outputName
            metadataEntries {
              label
              description
            }
         }
    }
  }
}
n
thanks, this is so cool it would save me a lot of time
c
No problem. There isn't currently a way to retrieve the output directly from graphQL, but attaching the output value as metadata is one workaround. Depending on the metadata type, you'll need to attach additional fields to
metadataEntries
. For example, for an string metadata type, you can write:
Copy code
metadataEntries {
  ... on TextMetadataEntry {
    text
  }
}