DRF and GraphQL Mesh Integration using OpenAPI method?

101 views Asked by At

I am relatively new to graphql-mesh and trying to understand. I have connected my graphql version of DRF to mesh and it worked but when I am trying to connect it using OpenAPI I get errors like

OpenAPI Integration Error

graphql-mesh configuration

package.json

{
    "name": "graphql-mesh",
    "private": true,
    "scripts": {
        "dev": "mesh dev"
    },
    "dependencies": {
        "@graphql-mesh/cli": "^0.88.5",
        "@graphql-mesh/graphql": "^0.96.3",
        "@graphql-mesh/openapi": "^0.97.5",
        "@graphql-mesh/runtime": "^0.97.4",
        "graphql": "^16.8.1"
    }
}

.meshrc.yml

sources:
  - name: DeveloperGround
    handler:
      openapi:
        source: http://localhost:8000/swagger.json
        baseurl: http://localhost:8000

DRF configuration

project/settings.py


INSTALLED_APPS = [
    ...
    'drf_yasg',
    'graphene_django',
]

project/urls.py


from graphene_django.views import GraphQLView

schema_view = get_schema_view(
   openapi.Info(
      title="Snippets API",
      default_version='v1',
      description="Check description",
   ),
   public=True,
   permission_classes=(permissions.AllowAny,),
)


urlpatterns = [
   path('admin/', admin.site.urls),
   path('category/', include('mobiledeveloper.urls')),

   path('swagger<format>/', schema_view.without_ui(cache_timeout=0), name='schema-json'),
   path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
   path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
   path('graphql/', csrf_exempt(GraphQLView.as_view(graphiql=True))),

   path(
        "openapi<format>",
        drf_schema_view(
            title="Project", description="OpenAPI", version="1.0.0"
        ),
        name="openapi-schema",
    ),
]

If I use graphql configuration for the mesh then it is working but not when using OpenAPI. There is no any authentication or authorization used. All the API request are AllowAny kind. And I have used OpenAPI of Stripe and it worked fine, so I am guessing here that my backend requires more work but i cannot figure out what kind of work is required. So that my backend can also be implemented to mesh using OpenAPI.

graphql-mesh configuration using graphql (working)

.meshrc.yml

sources:
  - name: DeveloperGround
    handler:
      graphql:
        endpoint: http://localhost:8000/graphql/

if anything else is required then comment. Thank you.

0

There are 0 answers