Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Sep 26, 2024
1 parent ddae38b commit b1f0676
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 47 deletions.
54 changes: 26 additions & 28 deletions generated/.tailcallrc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ directive @call(
of the previous step is passed as input to the next step.
"""
steps: [Step]
) on FIELD_DEFINITION | OBJECT
) on FIELD_DEFINITION

"""
The `@expr` operators allows you to specify an expression that can evaluate to a
Expand All @@ -55,6 +55,7 @@ The @graphQL operator allows to specify GraphQL API server request to fetch data
from.
"""
directive @graphQL(
allowed_headers: [String!]
"""
Named arguments for the requested field. More info [here](https://tailcall.run/docs/guides/operators/#args)
"""
Expand All @@ -64,12 +65,7 @@ directive @graphQL(
the one specified in the `@upstream` operator.
"""
baseURL: String
"""
If the upstream GraphQL server supports request batching, you can specify the 'batch'
argument to batch several requests into a single batch request.Make sure you have
also specified batch settings to the `@upstream` and to the `@graphQL` operator.
"""
batch: Boolean!
batch: Batch
"""
The headers parameter allows you to customize the headers of the GraphQL request
made by the `@graphQL` operator. It is used by specifying a key-value map of header
Expand All @@ -82,7 +78,8 @@ directive @graphQL(
field, Tailcall requests data from the corresponding upstream field.
"""
name: String!
) on FIELD_DEFINITION | OBJECT
query: [URLQuery]
) on FIELD_DEFINITION

"""
The @grpc operator indicates that a field or node is backed by a gRPC API.For instance,
Expand All @@ -94,11 +91,13 @@ In this scenario, the GraphQL server will make a gRPC request to the gRPC endpoi
specified when the `users` field is queried.
"""
directive @grpc(
allowedHeaders: [String!]
"""
This refers to the base URL of the API. If not specified, the default base URL is
the one specified in the `@upstream` operator.
"""
baseURL: String
batch: Batch
"""
The `batchKey` dictates the path Tailcall will follow to group the returned items
from the batch request. For more details please refer out [n + 1 guide](https://tailcall.run/docs/guides/n+1#solving-using-batching).
Expand All @@ -120,7 +119,8 @@ directive @grpc(
This refers to the gRPC method you're going to call. For instance `GetAllNews`.
"""
method: String!
) on FIELD_DEFINITION | OBJECT
onRequest: String
) on FIELD_DEFINITION

"""
The @http operator indicates that a field or node is backed by a REST API.For instance,
Expand All @@ -131,11 +131,13 @@ server will make a GET request to the API endpoint specified when the `users` fi
is queried.
"""
directive @http(
allowedHeaders: [String!]
"""
This refers to the base URL of the API. If not specified, the default base URL is
the one specified in the `@upstream` operator.
"""
baseURL: String
batch: Batch
"""
The `batchKey` dictates the path Tailcall will follow to group the returned items
from the batch request. For more details please refer out [n + 1 guide](https://tailcall.run/docs/guides/n+1#solving-using-batching).
Expand Down Expand Up @@ -190,7 +192,7 @@ directive @http(
is automatically selected as the batching parameter.
"""
query: [URLQuery]
) on FIELD_DEFINITION | OBJECT
) on FIELD_DEFINITION

directive @js(
name: String!
Expand Down Expand Up @@ -365,12 +367,6 @@ directive @upstream(
"""
baseURL: String
"""
An object that specifies the batch settings, including `maxSize` (the maximum size
of the batch), `delay` (the delay in milliseconds between each batch), and `headers`
(an array of HTTP headers to be included in the batch).
"""
batch: Batch
"""
The time in seconds that the connection will wait for a response before timing out.
"""
connectTimeout: Int
Expand Down Expand Up @@ -538,6 +534,12 @@ input Step {
query: String
}

input Batch {
delay: Int!
headers: [String!]
maxSize: Int
}

input KeyValue {
key: String!
value: String!
Expand Down Expand Up @@ -709,12 +711,6 @@ input TelemetryExporter {
apollo: Apollo
}

input Batch {
delay: Int!
headers: [String!]
maxSize: Int
}

input Proxy {
url: String!
}
Expand All @@ -724,6 +720,7 @@ The @graphQL operator allows to specify GraphQL API server request to fetch data
from.
"""
input GraphQL {
allowed_headers: [String!]
"""
Named arguments for the requested field. More info [here](https://tailcall.run/docs/guides/operators/#args)
"""
Expand All @@ -733,12 +730,7 @@ input GraphQL {
the one specified in the `@upstream` operator.
"""
baseURL: String
"""
If the upstream GraphQL server supports request batching, you can specify the 'batch'
argument to batch several requests into a single batch request.Make sure you have
also specified batch settings to the `@upstream` and to the `@graphQL` operator.
"""
batch: Boolean!
batch: Batch
"""
The headers parameter allows you to customize the headers of the GraphQL request
made by the `@graphQL` operator. It is used by specifying a key-value map of header
Expand All @@ -751,6 +743,7 @@ input GraphQL {
field, Tailcall requests data from the corresponding upstream field.
"""
name: String!
query: [URLQuery]
}

"""
Expand All @@ -763,11 +756,13 @@ In this scenario, the GraphQL server will make a gRPC request to the gRPC endpoi
specified when the `users` field is queried.
"""
input Grpc {
allowedHeaders: [String!]
"""
This refers to the base URL of the API. If not specified, the default base URL is
the one specified in the `@upstream` operator.
"""
baseURL: String
batch: Batch
"""
The `batchKey` dictates the path Tailcall will follow to group the returned items
from the batch request. For more details please refer out [n + 1 guide](https://tailcall.run/docs/guides/n+1#solving-using-batching).
Expand All @@ -789,6 +784,7 @@ input Grpc {
This refers to the gRPC method you're going to call. For instance `GetAllNews`.
"""
method: String!
onRequest: String
}

"""
Expand All @@ -800,11 +796,13 @@ server will make a GET request to the API endpoint specified when the `users` fi
is queried.
"""
input Http {
allowedHeaders: [String!]
"""
This refers to the base URL of the API. If not specified, the default base URL is
the one specified in the `@upstream` operator.
"""
baseURL: String
batch: Batch
"""
The `batchKey` dictates the path Tailcall will follow to group the returned items
from the batch request. For more details please refer out [n + 1 guide](https://tailcall.run/docs/guides/n+1#solving-using-batching).
Expand Down
1 change: 0 additions & 1 deletion src/core/app_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl AppContext {
for def in blueprint.definitions.iter_mut() {
if let Definition::Object(def) = def {
for field in &mut def.fields {
let of_type = field.of_type.clone();
field.map_expr(|expr| {
expr.modify(&mut |expr| match expr {
IR::IO(io) => match io {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: false,
},
),
Expand Down Expand Up @@ -137,6 +145,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: false,
},
),
Expand Down Expand Up @@ -213,6 +229,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: false,
},
),
Expand Down Expand Up @@ -293,6 +317,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: false,
},
),
Expand Down Expand Up @@ -689,6 +721,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: true,
},
),
Expand Down Expand Up @@ -751,6 +791,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: false,
},
),
Expand Down Expand Up @@ -850,6 +898,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: true,
},
),
Expand Down Expand Up @@ -924,6 +980,14 @@ Index {
group_by: None,
dl_id: None,
http_filter: None,
batch: Some(
Batch {
delay: 100,
headers: {},
max_size: None,
},
),
headers: {},
is_list: false,
},
),
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tailcall_typedefs_common::ServiceDocumentBuilder;
use super::directives::{Call, Expr, GraphQL, Grpc, Http, Key, JS};
use super::from_document::from_document;
use super::telemetry::Telemetry;
use super::{KeyValue, Link, Resolver, Server, Upstream};
use super::{Link, Resolver, Server, Upstream};
use crate::core::config::npo::QueryPath;
use crate::core::config::source::Source;
use crate::core::is_default;
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/directives/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Step {
schemars::JsonSchema,
DirectiveDefinition,
)]
#[directive_definition(locations = "FieldDefinition, Object")]
#[directive_definition(locations = "FieldDefinition")]
pub struct Call {
/// Steps are composed together to form a call.
/// If you have multiple steps, the output of the previous step is passed as
Expand Down
34 changes: 23 additions & 11 deletions src/core/config/directives/graphql.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::collections::BTreeSet;

use serde::{Deserialize, Serialize};
use tailcall_macros::{DirectiveDefinition, InputDefinition};

use crate::core::config::KeyValue;
use crate::core::config::{Batch, KeyValue, URLQuery};
use crate::core::is_default;

#[derive(
Expand All @@ -16,7 +18,7 @@ use crate::core::is_default;
DirectiveDefinition,
InputDefinition,
)]
#[directive_definition(locations = "FieldDefinition, Object")]
#[directive_definition(locations = "FieldDefinition")]
#[serde(deny_unknown_fields)]
/// The @graphQL operator allows to specify GraphQL API server request to fetch
/// data from.
Expand All @@ -30,15 +32,14 @@ pub struct GraphQL {
/// base URL is the one specified in the `@upstream` operator.
pub base_url: Option<String>,

#[serde(default, skip_serializing_if = "is_default")]
/// If the upstream GraphQL server supports request batching, you can
/// specify the 'batch' argument to batch several requests into a single
/// batch request.
///
/// Make sure you have also specified batch settings to the `@upstream` and
/// to the `@graphQL` operator.
pub batch: bool,

// #[serde(default, skip_serializing_if = "is_default")]
// /// If the upstream GraphQL server supports request batching, you can
// /// specify the 'batch' argument to batch several requests into a single
// /// batch request.
// ///
// /// Make sure you have also specified batch settings to the `@upstream` and
// /// to the `@graphQL` operator.
// pub batch: bool,
#[serde(default, skip_serializing_if = "is_default")]
/// The headers parameter allows you to customize the headers of the GraphQL
/// request made by the `@graphQL` operator. It is used by specifying a
Expand All @@ -49,5 +50,16 @@ pub struct GraphQL {
/// a field in your schema to a field in the upstream schema. When a query
/// is received for this field, Tailcall requests data from the
/// corresponding upstream field.
#[serde(default, skip_serializing_if = "is_default")]
pub name: String,
#[serde(default, skip_serializing_if = "is_default")]
pub query: Vec<URLQuery>,
#[serde(default, skip_serializing_if = "is_default")]
pub allowed_headers: BTreeSet<String>,
#[serde(default, skip_serializing_if = "is_default")]
pub batch: Option<Batch>,
// #[serde(default, skip_serializing_if = "is_default")]
// pub base_url: Option<String>,
// #[serde(default, skip_serializing_if = "is_default")]
// pub on_request: Option<String>,
}
Loading

0 comments on commit b1f0676

Please sign in to comment.