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

chore: refactor query parser #4822

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
4 changes: 3 additions & 1 deletion psl/psl-core/src/common/preview_features.rs
Expand Up @@ -78,7 +78,8 @@ features!(
UncheckedScalarInputs,
Views,
RelationJoins,
PrismaSchemaFolder
PrismaSchemaFolder,
ExcludeApi,
);

/// Generator preview features (alphabetically sorted)
Expand All @@ -95,6 +96,7 @@ pub const ALL_PREVIEW_FEATURES: FeatureMap = FeatureMap {
| Tracing
| Views
| RelationJoins
| ExcludeApi
}),
deprecated: enumflags2::make_bitflags!(PreviewFeature::{
AtomicNumberOperations
Expand Down
2 changes: 1 addition & 1 deletion psl/psl/tests/config/generators.rs
Expand Up @@ -258,7 +258,7 @@ fn nice_error_for_unknown_generator_preview_feature() {
.unwrap_err();

let expectation = expect![[r#"
error: The preview feature "foo" is not known. Expected one of: deno, driverAdapters, fullTextIndex, fullTextSearch, metrics, multiSchema, nativeDistinct, postgresqlExtensions, tracing, views, relationJoins
error: The preview feature "foo" is not known. Expected one of: deno, driverAdapters, fullTextIndex, fullTextSearch, metrics, multiSchema, nativeDistinct, postgresqlExtensions, tracing, views, relationJoins, excludeApi
--> schema.prisma:3
 | 
 2 |  provider = "prisma-client-js"
Expand Down
2 changes: 1 addition & 1 deletion query-engine/core-tests/Cargo.toml
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dev-dependencies]
dissimilar = "1.0.4"
user-facing-errors = { path = "../../libs/user-facing-errors" }
request-handlers = { path = "../request-handlers" }
request-handlers = { path = "../request-handlers", features=["native"] }
query-core = { path = "../core", features = ["metrics"] }
schema = { path = "../schema" }
psl.workspace = true
Expand Down
Expand Up @@ -20,6 +20,16 @@
"name": "dob",
"typeName": "DateTime",
"isRelation": false
},
{
"name": "posts",
"typeName": "Post[]",
"isRelation": true
},
{
"name": "_count",
"typeName": "UserCountOutputType",
"isRelation": false
}
]
},
Expand Down
Expand Up @@ -7,4 +7,14 @@ model User {
id Int @id
email String
dob DateTime?

posts Post[]
}

model Post {
id Int @id
name String

userId Int?
user User? @relation(fields: [userId], references: [id])
}
@@ -0,0 +1,10 @@
{
"action": "findMany",
"modelName": "User",
"query": {
"selection": {
"id": true,
"unknown_field": false
}
}
}
@@ -0,0 +1,15 @@
{
"action": "findMany",
"modelName": "User",
"query": {
"selection": {
"id": true,
"posts": {
"selection": {
"id": true,
"unknown_field": false
}
}
}
}
}
Expand Up @@ -54,6 +54,13 @@
"Null"
],
"required": false
},
{
"name": "posts",
"typeNames": [
"PostListRelationFilter"
],
"required": false
}
]
}
Expand Down
Expand Up @@ -20,6 +20,16 @@
"name": "dob",
"typeName": "DateTime",
"isRelation": false
},
{
"name": "posts",
"typeName": "Post[]",
"isRelation": true
},
{
"name": "_count",
"typeName": "UserCountOutputType",
"isRelation": false
}
]
},
Expand Down
@@ -0,0 +1,42 @@
{
"is_panic": false,
"message": "Field 'unknown_field' not found in enclosing type 'User'",
"meta": {
"kind": "UnknownSelectionField",
"outputType": {
"name": "User",
"fields": [
{
"name": "id",
"typeName": "Int",
"isRelation": false
},
{
"name": "email",
"typeName": "String",
"isRelation": false
},
{
"name": "dob",
"typeName": "DateTime",
"isRelation": false
},
{
"name": "posts",
"typeName": "Post[]",
"isRelation": true
},
{
"name": "_count",
"typeName": "UserCountOutputType",
"isRelation": false
}
]
},
"selectionPath": [
"findManyUser",
"unknown_field"
]
},
"error_code": "P2009"
}
@@ -0,0 +1,38 @@
{
"is_panic": false,
"message": "Field 'unknown_field' not found in enclosing type 'Post'",
"meta": {
"kind": "UnknownSelectionField",
"outputType": {
"name": "Post",
"fields": [
{
"name": "id",
"typeName": "Int",
"isRelation": false
},
{
"name": "name",
"typeName": "String",
"isRelation": false
},
{
"name": "userId",
"typeName": "Int",
"isRelation": false
},
{
"name": "user",
"typeName": "User",
"isRelation": true
}
]
},
"selectionPath": [
"findManyUser",
"posts",
"unknown_field"
]
},
"error_code": "P2009"
}
Expand Up @@ -54,6 +54,13 @@
"Null"
],
"required": false
},
{
"name": "posts",
"typeNames": [
"PostListRelationFilter"
],
"required": false
}
]
},
Expand Down
Expand Up @@ -20,6 +20,16 @@
"name": "dob",
"typeName": "DateTime",
"isRelation": false
},
{
"name": "posts",
"typeName": "Post[]",
"isRelation": true
},
{
"name": "_count",
"typeName": "UserCountOutputType",
"isRelation": false
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion query-engine/core/src/query_document/mod.rs
Expand Up @@ -23,7 +23,7 @@ mod transformers;

pub use argument_value::{ArgumentValue, ArgumentValueObject};
pub use operation::Operation;
pub use selection::{In, Selection, SelectionArgument, SelectionSet};
pub use selection::{Exclusion, In, Selection, SelectionArgument, SelectionSet};

pub(crate) use parse_ast::*;
pub(crate) use parser::*;
Expand Down