Skip to content

Commit

Permalink
graph: fix graphman not accepting table names
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Nov 13, 2023
1 parent 06bbe80 commit c2e1d4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions graph/src/schema/entity_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{borrow::Borrow, fmt, sync::Arc};

use anyhow::{Context, Error};
use inflector::Inflector;
use serde::Serialize;

use crate::{
Expand Down Expand Up @@ -168,38 +169,38 @@ impl std::hash::Hash for EntityType {
/// A trait to mark types that can reasonably turned into the name of an
/// entity type
pub trait AsEntityTypeName {
fn name(&self) -> &str;
fn name(&self) -> String;
}

impl AsEntityTypeName for &str {
fn name(&self) -> &str {
self
fn name(&self) -> String {
self.to_pascal_case()
}
}

impl AsEntityTypeName for &String {
fn name(&self) -> &str {
self.as_str()
fn name(&self) -> String {
self.to_pascal_case()
}
}

impl AsEntityTypeName for &s::ObjectType {
fn name(&self) -> &str {
&self.name
fn name(&self) -> String {
self.name.to_pascal_case()
}
}

impl AsEntityTypeName for &s::InterfaceType {
fn name(&self) -> &str {
&self.name
fn name(&self) -> String {
self.name.to_pascal_case()
}
}

impl AsEntityTypeName for ObjectOrInterface<'_> {
fn name(&self) -> &str {
fn name(&self) -> String {
match self {
ObjectOrInterface::Object(object) => &object.name,
ObjectOrInterface::Interface(interface) => &interface.name,
ObjectOrInterface::Object(object) => object.name.to_pascal_case(),
ObjectOrInterface::Interface(interface) => interface.name.to_pascal_case(),
}
}
}
2 changes: 1 addition & 1 deletion graph/src/schema/input_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl InputSchema {
let name = named.name();
self.inner
.pool
.lookup(name)
.lookup(&name)
.and_then(|atom| self.type_info(atom))
.map(|ti| EntityType::new(self.cheap_clone(), ti.name))
.ok_or_else(|| {
Expand Down

0 comments on commit c2e1d4e

Please sign in to comment.