Replies: 2 comments
-
I couldn't agree more with your suggestion. Any method might suffice as long as it works correctly. One thing we need to consider more seriously is how to run this feature. It could be included as one of Giganto’s command options, which would generate the schema file and then terminate. Any better ideas are welcome. |
Beta Was this translation helpful? Give feedback.
-
As discussed with Sophie, if we implement it exactly as described in the text, the build will fail when the schema file is missing. This is a current cyclic dependency issue in Giganto, regardless of the automation feature. (A schema file is required to generate a schema file.) The actions we can take here are:
Removing the Cyclic DependencyConclusion: Details: #[cfg(not(feature = "schema-generation"))]
mod client; Without modularization, every piece of schema-dependent code would require a feature check. Here are some examples:
// The same macro name is used differently based on the feature
#[cfg(not(feature = "schema-generation"))]
macro_rules! paged_events_in_cluster {
// ... implementation that uses the schema
}
#[cfg(feature="schema-generation")]
macro_rules! paged_events_in_cluster {
($($params:expr),*) => {
Ok(Connection::new(false, false))
}
}
#[derive(SimpleObject, Debug, ConvertGraphQLEdgesNode)]
#[graphql_client_type(names = [conn_raw_events::ConnRawEventsConnRawEventsEdgesNode, network_raw_events::NetworkRawEventsNetworkRawEventsEdgesNodeOnConnRawEvent])]
pub struct ConnRawEvents;
// becomes
#[derive(SimpleObject, Debug)]
#[cfg_attr(not(feature = "schema-generation"),
derive(ConvertGraphQLEdgesNode),
graphql_client_type(names = [
derives::conn_raw_events::DnsRawEventsDnsRawEventsEdgesNode,
derives::network_raw_events::NetworkRawEventsNetworkRawEventsEdgesNodeOnDnsRawEvent]))]
pub struct ConnRawEvents;
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/graphql/client/schema/schema.graphql",
query_path = "src/graphql/client/schema/network_raw_events.graphql",
response_derives = "Clone, PartialEq"
)]
// becomes
#[cfg_attr(not(feature = "schema-generation"),
derive(GraphQLQuery),
graphql(
schema_path = "src/graphql/client/schema/schema.graphql",
query_path = "src/graphql/client/schema/network_raw_events.graphql",
response_derives = "Clone, PartialEq"
)
)] |
Beta Was this translation helpful? Give feedback.
-
While working on #984, I found it cumbersome to manually generate GraphQL schema file every time a query changed. Automating this process offers several benefits:
It can be implemented as follows.
We can then specify the schema file path using the CLI argument
--export-schema-path ./src/graphql/client/schema/schema.graphql
. If we integrate auto-generation into the build process, the schema file can be excluded from version control.The above implementation is just one option that came to mind; the key concept is to automate schema generation for a smoother workflow. Your feedback and suggestions would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions