Skip to content

Commit eccf4fa

Browse files
committed
Add changelog ahead of 0.15.0
1 parent e9b3ca4 commit eccf4fa

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
- Support for `deprecated` directive on InputValue fields (#553)
11+
- Support for custom variable and response types (#536)
12+
- Allow using `#[derive(GraphQLQuery)]` without depending on `serde` directly (#487)
13+
- CLI option for extern enums (#520)
14+
- Support deserializing IDs from integers or strings (#476)
15+
- Introspection schema now includes `oneOf` and `specifiedByUrl` (#501)
16+
- Update `reqwest` to 0.12 (#499)
17+
- Fix required ID deserialization (#523)
18+
- Fix `skip_serializing_none` for root level variables (#485)
19+
- Use consistent reference to `graphql_client` crate in codegen (#484)
20+
- Fix multiple operations example in README (#497)
21+
822
## 0.14.0 - 2024-03-26
923

1024
- Add support for GraphQL’s `extend type` directive

graphql_client_codegen/src/codegen/inputs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ pub(super) fn generate_input_object_definitions(
1919
all_used_types
2020
.inputs(query.schema)
2121
.map(|(input_id, input)| {
22-
let custom_variable_type = query.query.variables.iter()
22+
let custom_variable_type = query
23+
.query
24+
.variables
25+
.iter()
2326
.enumerate()
24-
.find(|(_, v) | v.r#type.id.as_input_id().is_some_and(|i| i == input_id))
25-
.map(|(index, _)| custom_variable_types.get(index))
26-
.flatten();
27+
.find(|(_, v)| v.r#type.id.as_input_id().is_some_and(|i| i == input_id))
28+
.and_then(|(index, _)| custom_variable_types.get(index));
2729
if let Some(custom_type) = custom_variable_type {
2830
generate_type_def(input, options, custom_type)
2931
} else if input.is_one_of {
@@ -38,7 +40,7 @@ pub(super) fn generate_input_object_definitions(
3840
fn generate_type_def(
3941
input: &StoredInputType,
4042
options: &GraphQLClientCodegenOptions,
41-
custom_type: &String,
43+
custom_type: &str,
4244
) -> TokenStream {
4345
let custom_type = syn::parse_str::<syn::Path>(custom_type).unwrap();
4446
let normalized_name = options.normalization().input_name(input.name.as_str());

graphql_client_codegen/src/codegen/selection.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use crate::{
1212
},
1313
schema::{Schema, TypeId},
1414
type_qualifiers::GraphqlTypeQualifier,
15-
GraphQLClientCodegenOptions,
16-
GeneralError,
15+
GeneralError, GraphQLClientCodegenOptions,
1716
};
1817
use heck::*;
1918
use proc_macro2::{Ident, Span, TokenStream};
@@ -43,12 +42,27 @@ pub(crate) fn render_response_data_fields<'a>(
4342
if let Some(custom_response_type) = options.custom_response_type() {
4443
if operation.selection_set.len() == 1 {
4544
let selection_id = operation.selection_set[0];
46-
let selection_field = query.query.get_selection(selection_id).as_selected_field()
47-
.ok_or_else(|| GeneralError(format!("Custom response type {custom_response_type} will only work on fields")))?;
48-
calculate_custom_response_type_selection(&mut expanded_selection, response_data_type_id, custom_response_type, selection_id, selection_field);
45+
let selection_field = query
46+
.query
47+
.get_selection(selection_id)
48+
.as_selected_field()
49+
.ok_or_else(|| {
50+
GeneralError(format!(
51+
"Custom response type {custom_response_type} will only work on fields"
52+
))
53+
})?;
54+
calculate_custom_response_type_selection(
55+
&mut expanded_selection,
56+
response_data_type_id,
57+
custom_response_type,
58+
selection_id,
59+
selection_field,
60+
);
4961
return Ok(expanded_selection);
5062
} else {
51-
return Err(GeneralError(format!("Custom response type {custom_response_type} requires single selection field")));
63+
return Err(GeneralError(format!(
64+
"Custom response type {custom_response_type} requires single selection field"
65+
)));
5266
}
5367
}
5468

@@ -66,10 +80,10 @@ pub(crate) fn render_response_data_fields<'a>(
6680
fn calculate_custom_response_type_selection<'a>(
6781
context: &mut ExpandedSelection<'a>,
6882
struct_id: ResponseTypeId,
69-
custom_response_type: &'a String,
83+
custom_response_type: &'a str,
7084
selection_id: SelectionId,
71-
field: &'a SelectedField)
72-
{
85+
field: &'a SelectedField,
86+
) {
7387
let (graphql_name, rust_name) = context.field_name(field);
7488
let struct_name_string = full_path_prefix(selection_id, context.query);
7589
let field = context.query.schema.get_field(field.field_id);
@@ -88,7 +102,7 @@ fn calculate_custom_response_type_selection<'a>(
88102
name: struct_name_string.into(),
89103
});
90104
context.push_type_alias(TypeAlias {
91-
name: custom_response_type.as_str(),
105+
name: custom_response_type,
92106
struct_id,
93107
boxed: false,
94108
});

graphql_client_codegen/src/query/selection.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ pub(super) fn validate_type_conditions(
3535
let union = query.schema.get_union(union_id);
3636

3737
if !union
38-
.variants
39-
.iter()
40-
.any(|variant| *variant == selected_type)
38+
.variants.contains(&selected_type)
4139
{
4240
return Err(QueryValidationError::new(format!(
4341
"The spread {}... on {} is not valid.",

graphql_client_codegen/src/schema/json_conversion.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ fn ingest_enum(schema: &mut Schema, enm: &mut FullType) {
150150
std::mem::take(
151151
v.name
152152
.as_mut()
153-
.take()
154153
.expect("variant.name.as_mut().take()"),
155154
)
156155
})

0 commit comments

Comments
 (0)