Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(graph-gateway): add query selector extractor and check #561

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

LNSD
Copy link
Contributor

@LNSD LNSD commented Jan 25, 2024

This PR is an alternative to #561, where the query handler method is not split into two. This approach uses an "enum" extractor to differentiate when handling subgraph or deployment queries.

  • Add QuerySelector extractor
  • Set the tracing span selector field within the extractor
  • Early check if the selector is in the auth token allowlist

@LNSD LNSD self-assigned this Jan 25, 2024
@LNSD LNSD changed the title refactor(graph-gateway): add query selector extractor and auth check refactor(graph-gateway): add query selector extractor and check Jan 25, 2024
Comment on lines -88 to -98
// This is very useful for investigating gateway logs in production
let selector = match &resolved_deployments {
Ok((_, Some(subgraph))) => subgraph.id.to_string(),
Ok((deployments, None)) => deployments
.iter()
.map(|d| d.id.to_string())
.collect::<Vec<_>>()
.join(","),
Err(_) => "".to_string(),
};
span.record("selector", tracing::field::display(selector));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code snippet has been "moved" to the QuerySelector extractor:

https://github.com/edgeandnode/graph-gateway/blob/53286703ec172d5a1cdc0689c9baf1a6c53709e7/graph-gateway/src/client_query/query_selector.rs#L84-L85

This is equivalent since we are setting either the SubgraphId or the DeploymentId depending on the selector.

@LNSD LNSD requested a review from Theodus January 25, 2024 16:10
@LNSD LNSD marked this pull request as ready for review January 25, 2024 16:10
@LNSD
Copy link
Contributor Author

LNSD commented Jan 25, 2024

Aiming to merge this post v17.1.0 release

@LNSD LNSD force-pushed the lnsd/query-selector-extract-and-check branch from 07076bc to 6542b59 Compare January 25, 2024 16:26
Copy link
Member

@Theodus Theodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Theodus
Copy link
Member

Theodus commented Jan 25, 2024

Feel free to merge this now. I'm probably not finishing up the release until Monday

@LNSD LNSD merged commit ad55cdf into main Jan 25, 2024
2 checks passed
@LNSD LNSD deleted the lnsd/query-selector-extract-and-check branch January 25, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants