https://dagster.io/ logo
#ask-community
Title
# ask-community
n

noureddine

06/13/2022, 1:05 PM
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

claire

06/13/2022, 5:02 PM
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

noureddine

06/13/2022, 8:49 PM
thanks, this is so cool it would save me a lot of time
c

claire

06/13/2022, 8:55 PM
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
  }
}
4 Views