Skip to content

Commit

Permalink
fix: autogen scalar documentation (#1371)
Browse files Browse the repository at this point in the history
Co-authored-by: Tushar Mathur <[email protected]>
  • Loading branch information
mobley-trent and tusharmath authored Mar 12, 2024
1 parent 154d24f commit 1546ff3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
27 changes: 26 additions & 1 deletion autogen/src/gen_gql_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,23 @@ fn write_all_input_types(
.map(|(k, v)| (k.clone(), v.scalar()))
.collect::<Map<String, Schema>>();

let mut scalar_defs = BTreeMap::new();

for (name, obj) in scalar.iter() {
let scalar_definition = obj
.clone()
.into_object()
.object
.as_ref()
.and_then(|a| a.properties.get(name))
.and_then(|a| a.clone().into_object().metadata)
.and_then(|a| a.description);

if let Some(scalar_definition) = scalar_definition {
scalar_defs.insert(name.clone(), scalar_definition);
}
}

let defs = schema.definitions;

let mut scalar = scalar
Expand Down Expand Up @@ -666,7 +683,15 @@ fn write_all_input_types(
scalar_vector.sort();

for name in scalar_vector {
writeln!(writer, "scalar {name}")?;
if scalar_defs.contains_key(&name) {
let def = scalar_defs.get(&name).unwrap();
writeln!(writer, "\"\"\"")?;
writeln!(writer, "{def}")?;
writeln!(writer, "\"\"\"")?;
writeln!(writer, "scalar {name}")?;
} else {
writeln!(writer, "scalar {name}")?;
}
}

Ok(())
Expand Down
12 changes: 12 additions & 0 deletions generated/.tailcallrc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,21 @@ input Schema {
Arr: Schema
Opt: Schema
}
"""
A date string, such as 2007-12-03, is compliant with the full-date format outlined in section 5.6 of the RFC 3339 (https://datatracker.ietf.org/doc/html/rfc3339) profile of the ISO 8601 standard for the representation of dates and times using the Gregorian calendar.
"""
scalar Date
"""
field whose value conforms to the standard internet email address format as specified in HTML Spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address.
"""
scalar Email
"""
A field whose value conforms to the standard E.164 format as specified in E.164 specification (https://en.wikipedia.org/wiki/E.164).
"""
scalar PhoneNumber
"""
A field whose value conforms to the standard URL format as specified in RFC3986 (https://www.ietf.org/rfc/rfc3986.txt), and it uses real JavaScript URL objects.
"""
scalar Url
scalar JSON

1 comment on commit 1546ff3

@github-actions
Copy link

Choose a reason for hiding this comment

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

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 6.74ms 3.05ms 79.97ms 71.17%
Req/Sec 3.76k 283.97 4.19k 86.67%

448658 requests in 30.01s, 2.25GB read

Requests/sec: 14950.57

Transfer/sec: 76.74MB

Please sign in to comment.