Skip to content

feat: update samples subgraph to test#18

Open
mattprit-test[bot] wants to merge 1 commit into
mainfrom
samples-test
Open

feat: update samples subgraph to test#18
mattprit-test[bot] wants to merge 1 commit into
mainfrom
samples-test

Conversation

@mattprit-test
Copy link
Copy Markdown

@mattprit-test mattprit-test Bot commented May 30, 2025

Repository

Subgraph maintainers

@DiamondLightSource/ulims

@github-actions
Copy link
Copy Markdown

@@ -20,6 +20,12 @@ directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on
 
 directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
 
+input AddSampleEventInput
+  @join__type(graph: SAMPLES)
+{
+  description: String!
+}
+
 type Artifact
   @join__type(graph: WORKFLOWS)
 {
@@ -33,23 +39,99 @@ type Artifact
   mimeType: String!
 }
 
-"""
-Implement the DateTime<Utc> scalar
+input CreateOrValidateSampleInput
+  @join__type(graph: SAMPLES)
+{
+  """URL of the JSON schema the samples' `data` should be validated against"""
+  dataSchemaUrl: String!
 
-The input/output is a string in RFC3339 format.
-"""
+  """Number of the proposal the samples should be associated with"""
+  proposalNumber: Int!
+
+  """Number of the instrument session the samples should be associated with"""
+  instrumentSessionNumber: Int!
+
+  """Samples to be created"""
+  samples: [SampleIn!]!
+
+  """
+  Whether or not the provided samples should only be validated and not created
+  """
+  validateOnly: Boolean! = false
+}
+
+input CreateSampleInput
+  @join__type(graph: SAMPLES)
+{
+  proposalNumber: Int!
+  instrumentSessionNumber: Int!
+  samples: [SampleInLegacy!]!
+  validateOnly: Boolean! = false
+}
+
+"""Return type when creating or validating samples"""
+type CreateSamplesResponse
+  @join__type(graph: SAMPLES)
+{
+  """Whether the operation has succeeded without validation errors"""
+  success: Boolean!
+
+  """Samples that have been created"""
+  samples: [Sample!]!
+
+  """Errors that occurred during sample validation"""
+  errors: [SampleValidationError!]!
+}
+
+"""Date with time (isoformat)"""
 scalar DateTime
+  @join__type(graph: SAMPLES)
   @join__type(graph: WORKFLOWS)
 
+input DatetimeOperatorInput
+  @join__type(graph: SAMPLES)
+{
+  """
+  Will filter to items where the `DateTime` field is greater than (i.e. after) the provided value
+  """
+  gt: DateTime = null
+
+  """
+  Will filter to items where the `DateTime` field is less than (i.e. before) the provided value
+  """
+  lt: DateTime = null
+}
+
+"""The details of sample validation error"""
+type ErrorDetails
+  @join__type(graph: SAMPLES)
+{
+  """The type of error that occurred"""
+  type: String!
+
+  """
+  Tuple of strings identifying where in the sample schema the error occurred.
+  """
+  location: [String!]!
+
+  """A human readable error message."""
+  message: String!
+}
+
 scalar join__FieldSet
 
 enum join__Graph {
+  SAMPLES @join__graph(name: "samples", url: "https://sample-information.diamond.ac.uk/api/graphql")
   WORKFLOWS @join__graph(name: "workflows", url: "https://workflows.diamond.ac.uk/graphql")
 }
 
-"""A scalar that can represent any JSON value."""
+"""
+The `JSON` scalar type represents JSON values as specified by [ECMA-404](https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf).
+"""
 scalar JSON
+  @join__type(graph: SAMPLES)
   @join__type(graph: WORKFLOWS)
+  @specifiedBy(url: "https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf")
 
 """A scalar that can represent any JSON Object value."""
 scalar JSONObject
@@ -71,37 +153,210 @@ enum link__Purpose {
 
 """The root mutation of the service"""
 type Mutation
+  @join__type(graph: SAMPLES)
   @join__type(graph: WORKFLOWS)
 {
-  submitWorkflowTemplate(name: String!, visit: VisitInput!, parameters: JSON!): Workflow!
+  createSamples(input: CreateSampleInput!): [Sample!]! @join__field(graph: SAMPLES) @deprecated(reason: "Will be replaced by createOrValidateSamples")
+  createOrValidateSamples(input: CreateOrValidateSampleInput!): CreateSamplesResponse! @join__field(graph: SAMPLES)
+  sample(sampleId: UUID!): SampleMutations @join__field(graph: SAMPLES)
+  submitWorkflowTemplate(name: String!, visit: VisitInput!, parameters: JSON!): Workflow! @join__field(graph: WORKFLOWS)
 }
 
 """Information about pagination in a connection"""
 type PageInfo
+  @join__type(graph: SAMPLES)
   @join__type(graph: WORKFLOWS)
 {
-  """When paginating backwards, are there more items?"""
-  hasPreviousPage: Boolean!
-
-  """When paginating forwards, are there more items?"""
-  hasNextPage: Boolean!
-
   """When paginating backwards, the cursor to continue."""
   startCursor: String
 
   """When paginating forwards, the cursor to continue."""
   endCursor: String
+
+  """When paginating backwards, are there more items?"""
+  hasPreviousPage: Boolean!
+
+  """When paginating forwards, are there more items?"""
+  hasNextPage: Boolean!
 }
 
 """The root query of the service"""
 type Query
+  @join__type(graph: SAMPLES)
   @join__type(graph: WORKFLOWS)
 {
+  """Get a sample by its id"""
+  sample(sampleId: UUID!): Sample @join__field(graph: SAMPLES)
+
+  """Get a list of samples associated with a given instrument session"""
+  samples(proposalNumber: Int!, instrumentSessionNumber: Int!, first: Int!, filter: SampleFilterInput! = {}, before: String = null, after: String = null, last: Int = null, orderBy: SampleOrder! = {}): SampleConnection! @join__field(graph: SAMPLES)
+
   """Get a single [`Workflow`] by proposal, visit, and name"""
-  workflow(visit: VisitInput!, name: String!): Workflow!
-  workflows(visit: VisitInput!, cursor: String, limit: Int, filter: WorkflowFilter): WorkflowConnection!
-  workflowTemplate(name: String!): WorkflowTemplate!
-  workflowTemplates(cursor: String, limit: Int): WorkflowTemplateConnection!
+  workflow(visit: VisitInput!, name: String!): Workflow! @join__field(graph: WORKFLOWS)
+  workflows(visit: VisitInput!, cursor: String, limit: Int, filter: WorkflowFilter): WorkflowConnection! @join__field(graph: WORKFLOWS)
+  workflowTemplate(name: String!): WorkflowTemplate! @join__field(graph: WORKFLOWS)
+  workflowTemplates(cursor: String, limit: Int): WorkflowTemplateConnection! @join__field(graph: WORKFLOWS)
+}
+
+type Sample
+  @join__type(graph: SAMPLES)
+{
+  id: UUID!
+  name: String!
+  data: JSON!
+  createdTime: DateTime!
+  updatedTime: DateTime!
+  dataSchemaUrl: String!
+
+  """Samples from which this sample is derived"""
+  parents(first: Int = null, before: String = null, after: String = null, last: Int = null): SampleConnection!
+
+  """Samples derived from this sample"""
+  children(first: Int = null, before: String = null, after: String = null, last: Int = null): SampleConnection!
+
+  """Events linked to this sample"""
+  events(first: Int = null, before: String = null, after: String = null, last: Int = null): SampleEventConnection!
+
+  """The JSON schema that the sample's `data` conforms to"""
+  dataSchema: JSON!
+}
+
+type SampleConnection
+  @join__type(graph: SAMPLES)
+{
+  edges: [SampleEdge!]!
+  pageInfo: PageInfo!
+}
+
+type SampleEdge
+  @join__type(graph: SAMPLES)
+{
+  cursor: String!
+  node: Sample!
+}
+
+type SampleEvent
+  @join__type(graph: SAMPLES)
+{
+  id: UUID!
+  timestamp: DateTime!
+  description: String!
+}
+
+type SampleEventConnection
+  @join__type(graph: SAMPLES)
+{
+  edges: [SampleEventEdge!]!
+  pageInfo: PageInfo!
+}
+
+type SampleEventEdge
+  @join__type(graph: SAMPLES)
+{
+  cursor: String!
+  node: SampleEvent!
+}
+
+input SampleFilterInput
+  @join__type(graph: SAMPLES)
+{
+  """Filter on the `schemaUrl` field of `Sample`"""
+  schemaUrl: StringOperatorInput = null
+
+  """Filter on the `createdTime` field of `Sample`"""
+  createdTime: DatetimeOperatorInput = null
+
+  """Filter on the `createdTime` field of `Sample`"""
+  updatedTime: DatetimeOperatorInput = null
+
+  """Filter on the `name` field of `Sample`"""
+  name: StringOperatorInput = null
+}
+
+input SampleIn
+  @join__type(graph: SAMPLES)
+{
+  """Name of the sample"""
+  name: String!
+
+  """Data of the sample"""
+  data: JSON!
+}
+
+input SampleInLegacy
+  @join__type(graph: SAMPLES)
+{
+  name: String!
+  data: JSON!
+  dataSchemaUrl: String!
+  parentIds: [Int!] = null
+  children: [SampleInLegacy!] = null
+}
+
+type SampleMutations
+  @join__type(graph: SAMPLES)
+{
+  sampleId: UUID!
+  linkInstrumentSessionToSample(proposalNumber: Int!, instrumentSessionNumber: Int!): Void
+  addSampleEvent(sampleEvent: AddSampleEventInput!): SampleEvent!
+}
+
+input SampleOrder
+  @join__type(graph: SAMPLES)
+{
+  name: SortingOrder = null
+  createdTime: SortingOrder = null
+  updatedTime: SortingOrder = null
+}
+
+"""The details of errors occurred when validating a sample"""
+type SampleValidationError
+  @join__type(graph: SAMPLES)
+{
+  """
+  The index of the sample in CreateSampleInput.samples for which the error occurred
+  """
+  index: Int!
+
+  """Errors that occurred when validating the sample"""
+  errors: [ErrorDetails!]!
+}
+
+enum SortingOrder
+  @join__type(graph: SAMPLES)
+{
+  ASC @join__enumValue(graph: SAMPLES)
+  DESC @join__enumValue(graph: SAMPLES)
+}
+
+"""Conditions used to filter results based on the value of a String field"""
+input StringOperatorInput
+  @join__type(graph: SAMPLES)
+{
+  """
+  Will filter to items where the `String` field is equal to the provided value
+  """
+  eq: String = null
+
+  """
+  Will filter to items where the `String` field is not equal to the provided value
+  """
+  ne: String = null
+
+  """
+  Will filter to items where the `String` field is a member of the provided value
+  """
+  in: [String!] = null
+
+  """
+  Will filter to items where the `String` field is not a member of the provided value
+  """
+  nin: [String!] = null
+
+  """
+  Will filter to items where the `String` field is contains the provided value
+  """
+  contains: String = null
 }
 
 type Task
@@ -144,6 +399,9 @@ URL is a String implementing the [URL Standard](http://url.spec.whatwg.org/)
 scalar Url
   @join__type(graph: WORKFLOWS)
 
+scalar UUID
+  @join__type(graph: SAMPLES)
+
 """A visit to an instrument as part of a session"""
 type Visit
   @join__type(graph: WORKFLOWS)
@@ -172,6 +430,10 @@ input VisitInput
   number: Int!
 }
 
+"""Represents NULL values"""
+scalar Void
+  @join__type(graph: SAMPLES)
+
 type Workflow
   @join__type(graph: WORKFLOWS)
 {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants