Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error while trying to extend unified schema #4049

Open
Shreyasnie opened this issue Jun 17, 2022 Discussed in #4044 · 0 comments
Open

Getting error while trying to extend unified schema #4049

Shreyasnie opened this issue Jun 17, 2022 Discussed in #4044 · 0 comments

Comments

@Shreyasnie
Copy link

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>
@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
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

No branches or pull requests

1 participant