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

GraphQLHandler - Cannot use the introspection property #2783

Closed
angelsvirkov opened this issue Sep 9, 2021 · 2 comments
Closed

GraphQLHandler - Cannot use the introspection property #2783

angelsvirkov opened this issue Sep 9, 2021 · 2 comments

Comments

@angelsvirkov
Copy link
Contributor

angelsvirkov commented Sep 9, 2021

Describe the bug

The config.introspection property of a GraphQLHandler does not work properly. The problem comes from the fact that the GraphQLHandler expects the desctructured schema property from the urlLoader.handleSDL function, which in turn does not provide such property. Instead the handleSDL provides the parsed document.

Error:

TypeError: Cannot read property 'getQueryType' of undefined
    at /graphql-mesh-express/packages/backend/node_modules/@graphql-mesh/merger-stitching/index.js:31:57
    at Array.map (<anonymous>)
    at StitchingMerger.getUnifiedSchema (/graphql-mesh-express/packages/backend/node_modules/@graphql-mesh/merger-stitching/index.js:30:38)
    at Object.getMesh (/graphql-mesh-express/packages/backend/node_modules/@graphql-mesh/runtime/index.js:105:46)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Potential solution:

  1. I have a primitive solution proposal which is to return schema: graphql.buildSchema(schemaString) from the url loader but that touches another repo and probably it is better to have a solution here
  2. @ardatan , even if the bug is solved I am not sure if the introspection property which expects a URL path to SDL is the best way. For our use case, it would be a bit difficult to use because we might not have access to the sdl of a particular data source. Maybe a batter way would be to support a property which expects an endpoint to be introspected instrospectionEndpoint or an instrospection query result. What do you think? If you agree with me I could try implementing this myself - change the introspection to an introspectionEndpoint and remove the urlLoad.handleSDL() ?

To Reproduce

  1. Clone https://github.com/Kiesen/graphql-mesh-express
  2. Check out the feature/reuse-introspected-schema branch
  3. Follow the instructions on how to bootstrap the project
  4. Run npm start from the root folder

Environment:

Can be seen under https://github.com/Kiesen/graphql-mesh-express/tree/feature/reuse-introspected-schema

Additional context
Task 1) in to #2782

@ardatan
Copy link
Owner

ardatan commented Feb 18, 2022

Sorry for late reply. After our latest changes in Mesh, it seems to be working now.
Could you check my PR?
Kiesen/graphql-mesh-express#264

@ardatan ardatan closed this as completed Feb 18, 2022
@ardatan ardatan reopened this Feb 18, 2022
@angelsvirkov
Copy link
Contributor Author

angelsvirkov commented Mar 9, 2022

@ardatan , thank you very much. The issue is solved. We can now provide an introspection endpoint which is different than the endpoint for the data retrieval. This allows for moving forward with our encapsulation solution in which we use the same schema (introspected from service A) for 2 GraphQL Handlers with 2 different data retrieval endpoints (service A and Service B).

Do you think a recipe for what I described above with the encapsulation will be a good fit for the GQL Mesh docs? If that is the case I am up for adding this in the docs website

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

2 participants