graphql-datasource icon indicating copy to clipboard operation
graphql-datasource copied to clipboard

Setting of config.displayName appears to clash with Grafana handling of displayName

Open svet-b opened this issue 3 years ago • 3 comments

When multiple queries are used in a panel, and yield data series with the same name, Grafana normally takes care of this by appending "1", "2", "3", etc to the names. However, this does not appear to work correctly for data from the GraphQL data source. I've described the situation, and how to reproduce it, in this comment on a related (but now closed) Grafana issue: https://github.com/grafana/grafana/issues/31104#issuecomment-830302528.

From what I can tell, this is due to the fact that config.displayName is set here: https://github.com/fifemon/graphql-datasource/blob/master/src/DataSource.ts#L207, while Grafana does not expect it to be set by the datasource. Other datasources do not appear to do things this way, so I suspect the implementation in the GraphQL datasource is somehow non-standard.

svet-b avatar May 03 '21 17:05 svet-b

FWIW, this PR has some more details on what Grafana expects to receive - looks like there were some changes around v7.2: https://github.com/grafana/grafana/pull/27186. In this context, config.displayNameFromDS may be the correct way to pass the label.

svet-b avatar May 04 '21 14:05 svet-b

Thanks for digging into this issue. I agree that it does look like config.displayNameFromDS is the right field to set now.

retzkek avatar May 04 '21 14:05 retzkek

Hm...unfortunately field.config.displayNameFromDS still appears to lead to the same issue. (tried it in this fork branch https://github.com/ammpio/graphql-datasource/tree/ammp_v1.3.0a). I guess it would be good get some input on best practices from the Grafana devs. My best guess is still field.name

svet-b avatar May 04 '21 16:05 svet-b