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

Official Extension: GraphQL API Mocking #13

Open
oleg-nenashev opened this issue Apr 21, 2023 · 8 comments
Open

Official Extension: GraphQL API Mocking #13

oleg-nenashev opened this issue Apr 21, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@oleg-nenashev
Copy link
Member

oleg-nenashev commented Apr 21, 2023

Proposal

GraphQL becomes more and more popular, and services provide it along with classic REST APIs. It would be nice to support mocking of GraphQL requests with feature-rich request matching and response logic, including special extensions support

Implementation

References

@oleg-nenashev oleg-nenashev added the enhancement New feature or request label Apr 21, 2023
@kapishmalik
Copy link

@oleg-nenashev you can assign this issue to me. I will be working on the same.

@oleg-nenashev
Copy link
Member Author

Done!

@kapishmalik
Copy link

kapishmalik commented May 28, 2023

I went through this and figured out one of the approaches and discussed it with Tom.

We will be parsing GraphQL queries and converting them to Document objects(https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/language/Document.java). There is already a pre-written equality library for comparing these Document objects https://github.com/com2ghz/graphql-query-compare. I will be using the same and comparing GraphQL queries/objects. We can also write our comparator if required instead of using this.

We can also convert this Document Object to JSON and can use a JSON comparator if required.

Since this approach requires graphql-java to be part of JAR, we'll be implementing this as a core extension.

@oleg-nenashev
Copy link
Member Author

I am not sure this is what the equality matcher is what user would expect. GraphQL is basically a query with filters... a lot of them. So I do not see much value in comparing the requests with the reference, and I would rather expect processing on the handler level similar to a real GraphQL service.

One could also expect filtering by operation name (similar to HTTP request type), and maybe by arguments or some combinations.

@kapishmalik
Copy link

kapishmalik commented Jun 1, 2023

@oleg-nenashev I won't do any sort of exact match. I will be converting it to Document object which describes GraphQL query with all sort of filters. I would only be making necessary validations for equality to make sure that it corresponds to same query.

@oleg-nenashev
Copy link
Member Author

Ack! Ok, then no objections

@oleg-nenashev
Copy link
Member Author

oleg-nenashev commented Jun 9, 2023

As discussed with @kapishmalik and @tomakehurst , it should be rather implemented as an extension. I will move it to the Ecosystem repo until we have a better location

@kapishmalik could you please add the current design to the issues

@oleg-nenashev oleg-nenashev transferred this issue from wiremock/wiremock Jun 9, 2023
@oleg-nenashev oleg-nenashev changed the title GraphQL Request Matching Official Extension: GraphQL API Mocking Aug 29, 2023
@oleg-nenashev oleg-nenashev assigned nilwurtz and unassigned kapishmalik Nov 3, 2023
@oleg-nenashev
Copy link
Member Author

https://github.com/wiremock/wiremock-graphql-extension is now available for preview. Updated the state and assigned to @nilwurtz so that the roadmap entry is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Must Have
Development

No branches or pull requests

3 participants