I want to connect a REST API https://swapi.dev/api/ to API Mesh. My mesh.json looks like this:
{
"meshConfig": {
"sources": [
{
"name": "RESTSWAPI",
"handler": {
"openapi": {
"source": "https://swapi.dev/api/"
}
}
}
]
}
}
But I get this error message:
Your mesh errored out with the following error. Building Mesh with config: /usr/src/node-app/8ab88e57-f4dd-42a2-b6b1-c82e5b219704
at getGraphQLSchemaFromDereferencedJSONSchema (/usr/src/node-app/node_modules/@omnigraph/json-schema/index.js:2317:15)
at async OpenAPIHandler.getMeshSource (/usr/src/node-app/node_modules/@graphql-mesh/openapi/index.js:49:24)
at async /usr/src/node-app/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:133:28
at async Promise.allSettled (index 0)
at async getMesh (/usr/src/node-app/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:128:5)
at async Object.handler (/usr/src/node-app/node_modules/@graphql-mesh/cli/cjs/index.js:311:53)
at getMesh (/usr/src/node-app/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:167:15)
at async Object.handler (/usr/src/node-app/node_modules/@graphql-mesh/cli/cjs/index.js:311:53)
Is Star Wars API not a Open API / Swagger API?
Thank you for your help
Views
Replies
Total Likes
Hey @JanTa1,
The error you're encountering while trying to connect the Star Wars API (SWAPI) to API Mesh suggests a few potential issues, particularly with how the OpenAPI handler is being used in your mesh.json configuration.
The SWAPI, as available at https://swapi.dev/api/, is a RESTful API but it doesn't natively provide an OpenAPI (formerly known as Swagger) specification. The OpenAPI handler in GraphQL Mesh expects an OpenAPI specification to generate a GraphQL schema. Since SWAPI doesn't provide this, the process fails with the error message you're seeing.
Manual OpenAPI Specification:
Use a Different Handler:
Use GraphQL Mesh with Other APIs:
Check Community Resources:
Debugging and Logging:
Consult Documentation:
In summary, the primary issue here is the absence of an OpenAPI specification for SWAPI, which is required for the OpenAPI handler in GraphQL Mesh to function correctly. Exploring alternative handlers or creating a custom OpenAPI specification for SWAPI are potential ways to resolve this.
Regards,
Eugene
Views
Replies
Total Likes