Closed eddiecooro closed 5 years ago
This was discussed, but for the moment the templates and the model are really close to OpenAPI. Supporting multiple input formats requires a lot of refactoring... This is really long term vision.
cc: @jimschubert
Hi @jmini thankyou for reply
What do you mean by
Supporting multiple "input" formats
@Eddie-CooRo I think @jmini is referring the input of OpenAPI Generator, which currently supports OpenAPI spec at the moment.
@Eddie-CooRo as discussed, here is the high-level project plan:
I can probably start creating something tomorrow for you to try it out. Stay tuned.
I've cc'd @yarax who is the owner of https://github.com/yarax/swagger-to-graphql to see if we can collaborate on this.
Nice I am going to implement a sample graphql server in nodejs for given endpoints. So which library you think we should use? pure graphql-js or graphql-yoga(maintained by Prisma). I think graphql-yoga is a better choice because we can make use of
@wing328 @yarax
I've filed https://github.com/OpenAPITools/openapi-generator/pull/609 to create the 1st version of the GraphQL client generator. The Petstore samples can be found in https://github.com/OpenAPITools/openapi-generator/tree/af38f807f05cc6042187f4a50fe7e64597b75320/samples/client/petstore/graphql-client
Please test and comment on the code on what needs to be fixed.
I think graphql-yoga is a better choice because we can make use of
My suggestion is to start with whatever you feel comfortable. My view is that it's just a matter of time someone asks for graphql-js later
Hi!
I'd like to start a new project with documentation of type OAS3.0.0 first and then generate the GraphQL Server and possibly client out of it. I think I will work with next.js and apollo.
So what's the current state here? How can I help to get this finished? @wing328
@renepardon thanks for offering help to move this forward. Did you have a chance to review the output in https://github.com/OpenAPITools/openapi-generator/tree/graphql_client/samples/config/petstore/graphql? Does it look good to you?
Hi @wing328
not yet - can't get the current master building the whole stuff... Maybe it fails because of my JAVA-version? I would also start with a GraphQL server (based on express for simplicity)
$ java --version
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
At first glance the output looks good.
Let me merge the master into this branch so that you can build it with JDK10. Stay tuned.
It looks like the branch is already up to date but my problem was that I'm also not able to build the master branch.
Can you ping me via https://gitter.im (ID:wing328) so that I can help you resolve the build issue?
I would create a separate generator as „server generator“ and name it graphql-express-server which will output the types, queries, mutations and also the resolvers.
For the resolvers we may also adjust/use a custom field within the path definitions of the OAS config because my intention is to add a „microservice URI“ for each path so the resolver knows where to fetch the data from. We could use the "summary" or "description" field if no custom field is possible or even "tags".
Example path:
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- http://pets.example.com
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
cc @jmini @Eddie-CooRo
The current state is available here: https://github.com/renepardon/openapi-generator/tree/graphql_client/samples/server/petstore/graphql-server/openapi3graphql-server
But there is a problem with the types so the server won't start. A discussion about this has been started here: https://spectrum.chat/graphql/general?thread=9ee3d211-566d-4250-849c-2f8e4b42268c
I've adjusted the existing GraphQLSchemaGenerator class and added an AbstractGraphQLCodegen class as well.
Feedback is welcome @jmini @Eddie-CooRo @yarax
We've added the GraphQL generators via https://github.com/OpenAPITools/openapi-generator/pull/1603. Please pull the latest to give it a try.
Description
Adding support for graphql
Do you have any plan for a graphql generator or something similar? It would be nice if we can generate both rest and graphql endpoints from one specification.