Skip to content

Commit

Permalink
fix: fixing duplicate types (tailcallhq#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
shashitnak authored Feb 4, 2024
1 parent 01b4178 commit 834b196
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 221 deletions.
10 changes: 10 additions & 0 deletions autogen/src/gen_gql_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,19 @@ fn write_input_type(
defs: &BTreeMap<String, Schema>,
scalars: &mut HashSet<String>,
extra_it: &mut BTreeMap<String, ExtraTypes>,
types_added: &mut HashSet<String>,
) -> std::io::Result<()> {
let name = match input_whitelist_lookup(&name, extra_it) {
Some(name) => name,
None => return Ok(()),
};

if types_added.contains(name) {
return Ok(());
} else {
types_added.insert(name.to_string());
}

let description = typ
.metadata
.as_ref()
Expand Down Expand Up @@ -563,6 +570,7 @@ fn write_all_input_types(

let defs = schema.definitions;
let mut scalars = HashSet::new();
let mut types_added = HashSet::new();
for (name, input_type) in defs.iter() {
let mut name = name.clone();
first_char_to_upper(&mut name);
Expand All @@ -573,6 +581,7 @@ fn write_all_input_types(
&defs,
&mut scalars,
&mut extra_it,
&mut types_added,
)?;
}

Expand All @@ -589,6 +598,7 @@ fn write_all_input_types(
&defs,
&mut scalars,
&mut new_extra_it,
&mut types_added,
)?
}
}
Expand Down
221 changes: 0 additions & 221 deletions generated/.tailcallrc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -637,227 +637,6 @@ input Schema {
Arr: Schema
Opt: Schema
}
input Batch {
delay: Int!
headers: [String!]
maxSize: Int!
}
enum Encoding {
ApplicationJson
ApplicationXWwwFormUrlencoded
}
input ExprBody {
http: Http
grpc: Grpc
graphQL: GraphQL
const: JSON
if: ExprIf
and: [ExprBody]
or: [ExprBody]
cond: [ExprBody]
defaultTo: [ExprBody]
isEmpty: ExprBody
not: ExprBody
concat: [ExprBody]
intersection: [ExprBody]
difference: [[ExprBody]]
eq: [ExprBody]
gt: [ExprBody]
gte: [ExprBody]
lt: [ExprBody]
lte: [ExprBody]
max: [ExprBody]
min: [ExprBody]
pathEq: [ExprBody]
propEq: [ExprBody]
sortPath: [ExprBody]
symmetricDifference: [[ExprBody]]
union: [[ExprBody]]
mod: [ExprBody]
add: [ExprBody]
dec: ExprBody
divide: [ExprBody]
inc: ExprBody
multiply: [ExprBody]
negate: ExprBody
product: [ExprBody]
subtract: [ExprBody]
sum: [ExprBody]
}
input ExprIf {
"""
Condition to evaluate
"""
cond: ExprBody
"""
Expression to evaluate if the condition is false
"""
else: ExprBody
"""
Expression to evaluate if the condition is true
"""
then: ExprBody
}
"""
The @graphQL operator allows to specify GraphQL API server request to fetch data
from.
"""
input GraphQL {
"""
Named arguments for the requested field. More info [here](https://tailcall.run/docs/guides/operators/#args)
"""
args: KeyValues
"""
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
"""
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!
"""
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
names and their values.
"""
headers: KeyValues
"""
Specifies the root field on the upstream to request data from. This maps 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.
"""
name: String!
}
"""
The @grpc operator indicates that a field or node is backed by a gRPC API.For instance,
if you add the @grpc operator to the `users` field of the Query type with a service
argument of `NewsService` and method argument of `GetAllNews`, it signifies that
the `users` field is backed by a gRPC API. The `service` argument specifies the name
of the gRPC service. The `method` argument specifies the name of the gRPC method.
In this scenario, the GraphQL server will make a gRPC request to the gRPC endpoint
specified when the `users` field is queried.
"""
input Grpc {
"""
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
"""
This refers to the arguments of your gRPC call. You can pass it as a static object
or use Mustache template for dynamic parameters. These parameters will be added in
the body in `protobuf` format.
"""
body: String
"""
The key path in the response which should be used to group multiple requests. For
instance `["news","id"]`. For more details please refer out [n + 1 guide](https://tailcall.run/docs/guides/n+1#solving-using-batching).
"""
groupBy: [String!]
"""
The `headers` parameter allows you to customize the headers of the HTTP request made
by the `@grpc` operator. It is used by specifying a key-value map of header names
and their values. Note: content-type is automatically set to application/grpc
"""
headers: KeyValues
"""
This refers to the gRPC method you're going to call. For instance `GetAllNews`.
"""
method: String!
"""
The `protoPath` parameter allows you to specify the path to the proto file which
contains service and method definitions and is used to encode and decode the request
and response body.
"""
protoPath: String!
"""
This refers to the gRPC service you're going to call. For instance `NewsService`.
"""
service: String!
}
"""
The @http operator indicates that a field or node is backed by a REST API.For instance,
if you add the @http operator to the `users` field of the Query type with a path
argument of `"/users"`, it signifies that the `users` field is backed by a REST API.
The path argument specifies the path of the REST API. In this scenario, the GraphQL
server will make a GET request to the API endpoint specified when the `users` field
is queried.
"""
input Http {
"""
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
"""
The body of the API call. It's used for methods like POST or PUT that send data to
the server. You can pass it as a static object or use a Mustache template to substitute
variables from the GraphQL variables.
"""
body: String
"""
The `encoding` parameter specifies the encoding of the request body. It can be `ApplicationJson`
or `ApplicationXWwwFormUrlEncoded`. @default `ApplicationJson`.
"""
encoding: Encoding
"""
The `groupBy` parameter groups multiple data requests into a single call. For more
details please refer out [n + 1 guide](https://tailcall.run/docs/guides/n+1#solving-using-batching).
"""
groupBy: [String!]
"""
The `headers` parameter allows you to customize the headers of the HTTP request made
by the `@http` operator. It is used by specifying a key-value map of header names
and their values.
"""
headers: KeyValues
"""
Schema of the input of the API call. It is automatically inferred in most cases.
"""
input: Schema
"""
This refers to the HTTP method of the API call. Commonly used methods include `GET`,
`POST`, `PUT`, `DELETE` etc. @default `GET`.
"""
method: Method
"""
Schema of the output of the API call. It is automatically inferred in most cases.
"""
output: Schema
"""
This refers to the API endpoint you're going to call. For instance https://jsonplaceholder.typicode.com/users`.For
dynamic segments in your API endpoint, use Mustache templates for variable substitution.
For instance, to fetch a specific user, use `/users/{{args.id}}`.
"""
path: String!
"""
This represents the query parameters of your API call. You can pass it as a static
object or use Mustache template for dynamic parameters. These parameters will be
added to the URL.
"""
query: KeyValues
}
enum HttpVersion {
HTTP1
HTTP2
}
enum Method {
GET
POST
PUT
PATCH
DELETE
HEAD
OPTIONS
CONNECT
TRACE
}
input Proxy {
url: String!
}
scalar KeyValues
scalar JSON

0 comments on commit 834b196

Please sign in to comment.