Skip to content

Commit 9af26cf

Browse files
committed
Update naming to match conventions
1 parent 44a2fad commit 9af26cf

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/graphql/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ impl CurrentConfiguration {
314314
}
315315

316316
#[derive(Debug, InputObject)]
317-
struct TemplateInput {
317+
struct NamedTemplateInput {
318318
name: String,
319-
template: String,
319+
template: InputTemplate<ScanTemplate>,
320320
}
321321

322322
#[derive(Debug, Display, Error)]
@@ -421,17 +421,17 @@ impl Query {
421421
async fn named_templates<'ctx>(
422422
&self,
423423
ctx: &Context<'ctx>,
424-
beamline: String,
424+
instrument: String,
425425
names: Option<Vec<String>>,
426426
) -> async_graphql::Result<Vec<NamedTemplate>> {
427427
check_auth(ctx, |policy, token| {
428-
policy.check_instrument_admin(token, &beamline)
428+
policy.check_instrument_admin(token, &instrument)
429429
})
430430
.await?;
431431
let db = ctx.data::<SqliteScanPathService>()?;
432432
match names {
433-
Some(names) => Ok(db.additional_templates(&beamline, names).await?),
434-
None => Ok(db.all_additional_templates(&beamline).await?),
433+
Some(names) => Ok(db.additional_templates(&instrument, names).await?),
434+
None => Ok(db.all_additional_templates(&instrument).await?),
435435
}
436436
}
437437
}
@@ -530,13 +530,16 @@ impl Mutation {
530530
async fn register_template<'ctx>(
531531
&self,
532532
ctx: &Context<'ctx>,
533-
beamline: String,
534-
template: TemplateInput,
533+
instrument: String,
534+
template: NamedTemplateInput,
535535
) -> async_graphql::Result<NamedTemplate> {
536-
check_auth(ctx, |pc, token| pc.check_instrument_admin(token, &beamline)).await?;
536+
check_auth(ctx, |pc, token| {
537+
pc.check_instrument_admin(token, &instrument)
538+
})
539+
.await?;
537540
let db = ctx.data::<SqliteScanPathService>()?;
538541
Ok(db
539-
.register_template(&beamline, template.name, template.template)
542+
.register_template(&instrument, template.name, template.template.to_string())
540543
.await?)
541544
}
542545
}

static/service_schema.graphql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,19 @@ type Mutation {
124124
Add or modify the stored configuration for an instrument
125125
"""
126126
configure(instrument: String!, config: ConfigurationUpdates!): CurrentConfiguration!
127-
registerTemplate(beamline: String!, template: TemplateInput!): NamedTemplate!
127+
registerTemplate(instrument: String!, template: NamedTemplateInput!): NamedTemplate!
128128
}
129129

130130
type NamedTemplate {
131131
name: String!
132132
template: String!
133133
}
134134

135+
input NamedTemplateInput {
136+
name: String!
137+
template: ScanTemplate!
138+
}
139+
135140
"""
136141
Queries relating to numtracker configurations that have no side-effects
137142
"""
@@ -150,7 +155,7 @@ type Query {
150155
Can be filtered to provide one or more specific instruments
151156
"""
152157
configurations(instrumentFilters: [String!]): [CurrentConfiguration!]!
153-
namedTemplates(beamline: String!, names: [String!]): [NamedTemplate!]!
158+
namedTemplates(instrument: String!, names: [String!]): [NamedTemplate!]!
154159
}
155160

156161
"""
@@ -189,11 +194,6 @@ scalar ScanTemplate
189194

190195
scalar Subdirectory
191196

192-
input TemplateInput {
193-
name: String!
194-
template: String!
195-
}
196-
197197
"""
198198
Directs the executor to include this field or fragment only when the `if` argument is true.
199199
"""

0 commit comments

Comments
 (0)