Open
Description
Discussed in #4044
Originally posted by Shreyasnie June 16, 2022
We have two source following are the graphql schema.
OperationResponse
type OperationsResponses {
AuditLastUpdate: datetime2!
Description: String
EndTime: datetime2
Id: Int!
LastUpdateDateTimeUtc: datetime2!
OperationsType: Int!
PublicationDateTimeUtc: datetime2!
ResponseState: String
}
Production
type Production {
id: ID!
operation_request_id: String!
operation_response_id: String!
shift(filter: ShiftFilter, order: ShiftOrder, first: Int, offset: Int): [Shift]
}
type Shift {
id: ID!
operation_time: DateTime
operation_time_duration: Int
planned_downtime: DateTime
planned_downtime_duration: Int
unplanned_downtime: DateTime
unplanned_downtime_duration: Int
produce(filter: ProductionFilter): Production
}
type query {
getProduction(operation_response_id: String): Production
}
when i try to extend the operation response schema with production information i;e the relationship is Production.operation_response_id and OperationsResponses.Id
following the configuration in meshrc.yml
additionalTypeDefs: |
extend type OperationsResponses {
Production: Production
}
additionalResolvers:
- './resolvers'
following the resolver.ts
import { Resolvers } from './.mesh'
const resolvers: Resolvers = {
OperationsResponses: {
Production: {
selectionSet: /* GraphQL */`
{
operation_response_id
}
`,
resolve: async (root, _args, context, info) => {
return await context['Shift Model Flexible Model'].Query.getProduction({
root,
args: {
operation_response_id : root.Id.toString()
},
context,
info,
})
}
}
},
}
export default resolvers
I am able to see production inside operation response in graphql mesh gateway playground but when i query get below error from graphql tools
GraphQLError: not a valid GraphQL query
at C:\Source\Repos\graphql.wtf-graphql-mesh-as-a-gateway-main\node_modules\@graphql-tools\batch-execute\index.js:318:39
at Array.forEach (<anonymous>)
at splitResult (C:\Source\Repos\graphql.wtf-graphql-mesh-as-a-gateway-main\node_modules\@graphql-tools\batch-execute\index.js:316:30)
at C:\Source\Repos\graphql.wtf-graphql-mesh-as-a-gateway-main\node_modules\@graphql-tools\batch-execute\index.js:361:20
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
at async DataLoader.batchExecuteLoadFn [as _batchLoadFn] (C:\Source\Repos\graphql.wtf-graphql-mesh-as-a-gateway-main\node_modules\@graphql-tools\batch-execute\index.js:358:25)
Below is the query i tried to execute
query MyQuery {
OperationsResponses {
Production {
id
shift {
planned_downtime
planned_downtime_duration
}
}
}
}
and response I got is below
{
"errors": [
{
"message": "not a valid GraphQL query",
"path": [
"OperationsResponses"
]
}
],
"data": null
}
```</div>
Metadata
Metadata
Assignees
Labels
No labels