Skip to content

Commit

Permalink
codegen: improve error messages
Browse files Browse the repository at this point in the history
This is an initial step. Further improvements could offer suggestions
for what is available.

See #97.
  • Loading branch information
mathstuf committed Sep 10, 2018
1 parent 09b69a9 commit 9920c1d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions graphql_query_derive/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,26 @@ pub(crate) fn response_for_query(
.find(|op| op.name == selected_operation)
.map(|i| i.to_owned());

let operation = context.selected_operation.clone().unwrap_or_else(|| {
let opt_operation = context.selected_operation.clone().or_else(|| {
operations
.iter()
.next()
.map(|i| i.to_owned())
.expect("no operation in query document")
});
let operation = if let Some(operation) = opt_operation {
operation
} else {
panic!("no operation '{}' in query document", selected_operation);
};

let response_data_fields = {
let root_name: String = operation
.root_name(&context.schema)
.expect("operation type not in schema");
let opt_root_name = operation
.root_name(&context.schema);
let root_name: String = if let Some(root_name) = opt_root_name {
root_name
} else {
panic!("operation type '{:?}' not in schema", operation.operation_type);
};
let definition = context
.schema
.objects
Expand Down

0 comments on commit 9920c1d

Please sign in to comment.