Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/extra-query-avoid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
hive-router-query-planner: patch
router: patch
node-addon: patch
---

# Avoid extra `query` prefix for anonymous queries

When there is no variable definitions and no operation name, GraphQL queries can be sent without the `query` prefix. For example, instead of sending:

```diff
- query {
+ {
user(id: "1") {
name
}
}
```
1 change: 1 addition & 0 deletions .gemini/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ async fn handle(user: &User, req: &Request) -> Result<Response> {
We are using `knope` with changesets for declaring changes. If you detect a new file in a PR under `.changeset/` directory, please confirm the following rules:

- Every new `changesets` file that touches `query-planner` must have a `router` changeset - either in the same changeset or a separate changeset.
- Every new `changesets` file that touches `query-planner` must have a `node-addon` changeset - either in the same changeset or a separate changeset.
- Every new `changesets` file that touches `executor` must have a `query-planner` changeset - either in the same changeset or a separate changeset.
- If a PR touches `config` crate and adds/changes to the `HiveRouterConfig` struct, it must have a `router` changeset that contains a YAML example on how the configuration needs to be used.
38 changes: 19 additions & 19 deletions bin/router/src/pipeline/authorization/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mod field_authorization {

insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["me"]
"#);
}
Expand All @@ -219,7 +219,7 @@ mod field_authorization {

insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["my_account"]
"#);
}
Expand All @@ -241,7 +241,7 @@ mod field_authorization {

insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["posts.internalNotes"]
"#);
}
Expand All @@ -268,7 +268,7 @@ mod field_authorization {

insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["posts.comments"]
"#);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ mod type_authorization {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{media{score}}
Operation: {media{score}}
Errors: ["media.id"]
"#);
}
Expand All @@ -520,7 +520,7 @@ mod type_authorization {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{media{...on Book{score} ...on Movie{score}}}
Operation: {media{...on Book{score} ...on Movie{score}}}
Errors: ["media.id", "media.id"]
"#);
}
Expand Down Expand Up @@ -838,7 +838,7 @@ mod fragments {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["node"]
"#);
}
Expand All @@ -864,7 +864,7 @@ mod fragments {
let decision = supergraph_data.decide(Some(vec!["read:user"]), query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title} node(id: "id"){id ...on User{uid: id}}}
Operation: {posts{title} node(id: "id"){id ...on User{uid: id}}}
Errors: ["node.username"]
"#);
}
Expand Down Expand Up @@ -918,7 +918,7 @@ mod fragments {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["posts.comments"]
"#);
}
Expand Down Expand Up @@ -946,7 +946,7 @@ mod fragments {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title}}
Operation: {posts{title}}
Errors: ["node"]
"#);
}
Expand Down Expand Up @@ -974,7 +974,7 @@ mod fragments {
let decision = supergraph_data.decide(Some(vec!["read:user"]), query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{posts{title} node(id: "id"){id ...on User{uid: id}}}
Operation: {posts{title} node(id: "id"){id ...on User{uid: id}}}
Errors: ["node.username"]
"#);
}
Expand Down Expand Up @@ -1047,7 +1047,7 @@ mod variable_cleanup {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{version}
Operation: {version}
Errors: ["node"]
"#);
}
Expand Down Expand Up @@ -1455,7 +1455,7 @@ mod authenticated_directive {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{publicPosts{id title}}
Operation: {publicPosts{id title}}
Errors: ["me"]
"#);
}
Expand Down Expand Up @@ -1525,7 +1525,7 @@ mod authenticated_directive {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{publicPosts{id title}}
Operation: {publicPosts{id title}}
Errors: ["publicPosts.author"]
"#);
}
Expand Down Expand Up @@ -1944,7 +1944,7 @@ mod authenticated_directive {
// optionalUser is nullable and unauthorized - should be marked as UnauthorizedNullable
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{publicData}
Operation: {publicData}
Errors: ["privateUser", "optionalUser"]
"#);
}
Expand Down Expand Up @@ -2089,7 +2089,7 @@ mod authenticated_directive {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{publicPosts{id title}}
Operation: {publicPosts{id title}}
Errors: ["adminPanel"]
"#);
}
Expand All @@ -2113,7 +2113,7 @@ mod authenticated_directive {
let decision = supergraph_data.decide(Some(vec![]), query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{publicPosts{id}}
Operation: {publicPosts{id}}
Errors: ["adminPanel"]
"#);
}
Expand Down Expand Up @@ -2159,7 +2159,7 @@ mod authenticated_directive {
let decision = supergraph_data.decide(Some(vec!["admin"]), query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{adminPanel{settings{theme}}}
Operation: {adminPanel{settings{theme}}}
Errors: ["adminPanel.users"]
"#);
}
Expand Down Expand Up @@ -2208,7 +2208,7 @@ mod authenticated_directive {
let decision = supergraph_data.decide(None, query);
insta::assert_snapshot!(decision, @r#"
[Modified]
Operation: query{publicPosts{id}}
Operation: {publicPosts{id}}
Errors: ["profile"]
"#);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/node-addon/tests.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ exports[`fixtures > should plan federation-example/query.graphql 1`] = `
"nodes": [
{
"kind": "Fetch",
"operation": "query{topProducts{__typename upc name price weight}}",
"operation": "{topProducts{__typename upc name price weight}}",
"operationKind": "query",
"serviceName": "products"
},
{
"kind": "Fetch",
"operation": "query{users{__typename id username name}}",
"operation": "{users{__typename id username name}}",
"operationKind": "query",
"serviceName": "accounts"
}
Expand Down Expand Up @@ -524,7 +524,7 @@ exports[`fixtures > should plan simple-inaccessible/test-2.graphql 1`] = `
"kind": "QueryPlan",
"node": {
"kind": "Fetch",
"operation": "query{usersInFriends{id friends(type: FRIEND){id}}}",
"operation": "{usersInFriends{id friends(type: FRIEND){id}}}",
"operationKind": "query",
"serviceName": "friends"
}
Expand Down
Loading
Loading