Converting Smithy to GraphQL?
We have a plan to use Smithy to generate OpenAPI definition for our new project. Smithy provides nice experience for our needs and then we hope that generate GraphQL schema by using Smithy.
Is it nice idea? If so, I think I will write a smithy plugin to generate GraphQL schema.
Thanks for opening this issue!
Are you only interested in converting to GraphQL schema? Or were you thinking also about a some kind of connector or client that could make requests to a service?
Are you only interested in converting to GraphQL schema? Or were you thinking also about a some kind of connector or client that could make requests to a service?
Only converting to GraphQL schema. I think that the kind of tools are already exists and it will make (language | environment) dependencies.
I'm trying to write some code.
The current code of Smithy (includes plugins) is not dependent on any third-party libraries in its implementations. Is it your policy? If not so, can I use some libraries to handle GraphQL easily?
Generally, yes, we avoid dependencies as much as possible. However, plugins don’t have to be part of our core libraries can pull in dependencies as needed.
+1 for a GraphQL Schema generator.
Currently one can use OpenAPI Generator to do the job but we prefer a generator that can directly generate GraphQL schema from Smithy:
$ openapi-generator generate -g graphql-schema -i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml -o /tmp/graphql-schema
[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - Output directory (/tmp/graphql-schema) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: graphql-schema (schema)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'graphql-schema' is considered stable.
[main] INFO o.o.codegen.DefaultGenerator - Model Pets not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/graphql-schema/openapi2graphql/model/error.graphql
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/graphql-schema/openapi2graphql/model/pet.graphql
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/graphql-schema/openapi2graphql/api/pets_api.graphql
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/graphql-schema/.openapi-generator-ignore
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/graphql-schema/.openapi-generator/VERSION
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/graphql-schema/.openapi-generator/FILES
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################