Skip to content

Having a hard time with Unions #1162

Answered by ilslv
twiclo asked this question in Q&A
Discussion options

You must be logged in to vote

@twiclo for now you have to specify #[graphql(context = Context)]/#[graphql_object(context = Context)] on every GraphQL type:

#[derive(sqlx::FromRow, Deserialize, Debug, Default)]
pub struct Location {
	pub location_id: i32,
	pub address_id: Option<i32>,
	// #[sqlx(rename = "lat")]
	// #[sqlx(rename = "lng")]
	pub coordinate: String,
	pub location_source_id: i32,
	pub active: bool
}

#[derive(Serialize, Deserialize, sqlx::FromRow, sqlx::Decode, Debug, Default)]
pub struct Coordinate {
	pub lat: f64,
	pub lng: f64
}

#[derive(GraphQLObject, Debug)]
#[graphql(context = Context)]
pub struct GeoJSON { pub geojson: String }

#[derive(GraphQLEnum)]
#[graphql(context = Context)]
pub enum CoordFmt {

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by twiclo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants