question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate API/Services after importing into Microcks

See original GitHub issue

In a local Microcks (v.1.5.1-SNAPSHOT) I imported a graphql schema and a postman collection with mocked data, and another postman collection for rest services.

After that I exported the snapshot that I imported via api/import endpoint to Microcks which I bootstraps using the Helm package manager.

I tried to get the services I imported via the api/services endpoint and they returned duplicates and when I tried to call an endpoint to return the mocked data this is the error message:

7:29:29.646 [ERROR] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.IncorrectResultSizeDataAccessException: Query { "$java" : Query: { "name" : "XXX API", "version" : "1.0"}, Fields: {}, Sort: {} } returned non unique result.] with root cause org.springframework.dao.IncorrectResultSizeDataAccessException: Query { "$java" : Query: { "name" : "XXX API", "version" : "1.0"}, Fields: {}, Sort: {} } returned non unique result

I have already talked to @hguerrero about this issue

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lbroudouxcommented, Mar 24, 2022

For now, I was not able to reproduce duplicate imports when importing back on Microcks running on docker-compose.

Here’s for reference the content of the microcks-repository.json export file:

{
    "services": [
        {
            "id": "61a8fb5ce0de790a9fc15e10",
            "name": "Movie Graph API",
            "version": "1.0",
            "xmlNS": null,
            "type": "GRAPHQL",
            "metadata": {
                "createdOn": 1638464348723,
                "lastUpdate": 1640010039415,
                "annotations": null,
                "labels": {
                    "domain": "movie",
                    "status": "alpha"
                }
            },
            "sourceArtifact": "films.graphql",
            "operations": [
                {
                    "name": "allFilms",
                    "method": "QUERY",
                    "action": null,
                    "inputName": null,
                    "outputName": "FilmsConnection",
                    "bindings": null,
                    "dispatcher": null,
                    "dispatcherRules": null,
                    "defaultDelay": null,
                    "resourcePaths": null,
                    "parameterConstraints": null
                },
                {
                    "name": "film",
                    "method": "QUERY",
                    "action": null,
                    "inputName": "String",
                    "outputName": "Film",
                    "bindings": null,
                    "dispatcher": "QUERY_ARGS",
                    "dispatcherRules": "id",
                    "defaultDelay": null,
                    "resourcePaths": null,
                    "parameterConstraints": null
                },
                {
                    "name": "addStar",
                    "method": "MUTATION",
                    "action": null,
                    "inputName": "String",
                    "outputName": "Film",
                    "bindings": null,
                    "dispatcher": "QUERY_ARGS",
                    "dispatcherRules": "filmId",
                    "defaultDelay": null,
                    "resourcePaths": null,
                    "parameterConstraints": null
                },
                {
                    "name": "addReview",
                    "method": "MUTATION",
                    "action": null,
                    "inputName": "String, Review",
                    "outputName": "Film",
                    "bindings": null,
                    "dispatcher": "JSON_BODY",
                    "dispatcherRules": "{\n  \"exp\": \"/filmId\",\n  \"operator\": \"equals\",\n  \"cases\": {\n    \"ZmlsbXM6Mg==\": \"addReview to ZmlsbXM6Mg==\",\n    \"default\": \"ZmlsbXM6Mg==\"\n  }\n}",
                    "defaultDelay": 0,
                    "resourcePaths": null,
                    "parameterConstraints": []
                }
            ]
        }
    ],
    "resources": [
        {
            "id": "61c09137aed37b14889dfa19",
            "name": "Movie Graph API-1.0.graphql",
            "path": null,
            "content": "# microcksId: Movie Graph API : 1.0\nschema {\n    query: Query\n    mutation: Mutation\n}\ntype Film {\n    id: String!\n    title: String!\n    episodeID: Int!\n    director: String!\n    starCount: Int!\n    rating: Float!\n}\n\ntype FilmsConnection {\n    totalCount: Int!\n    films: [Film]\n}\n\ninput Review {\n    comment: String\n    rating: Int\n}\n\ntype Query {\n    allFilms: FilmsConnection\n    film(id: String): Film\n}\n\ntype Mutation {\n    addStar(filmId: String): Film\n    addReview(filmId: String, review: Review): Film\n}\n\n",
            "type": "GRAPHQL_SCHEMA",
            "serviceId": "61a8fb5ce0de790a9fc15e10",
            "sourceArtifact": "films.graphql"
        }
    ],
    "requests": [
        {
            "name": "allFilms",
            "content": "query allFilms {\n    allFilms {\n        films {\n            id\n            title\n            episodeID\n            director\n            starCount\n            rating\n        }\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-allFilms",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28163",
            "responseId": "61c09bfb14561b578ad28162",
            "queryParameters": null
        },
        {
            "name": "film ZmlsbXM6MQ==",
            "content": "query film ($id: String) {\n    film (id: \"ZmlsbXM6MQ==\") {\n        id\n        title\n        episodeID\n        director\n        starCount\n        rating\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-film",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28165",
            "responseId": "61c09bfb14561b578ad28164",
            "queryParameters": null
        },
        {
            "name": "film ZmlsbXM6Mg==",
            "content": "query film ($id: String) {\n    film (id: \"ZmlsbXM6Mg==\") {\n        id\n        title\n        episodeID\n        director\n        starCount\n        rating\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-film",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28167",
            "responseId": "61c09bfb14561b578ad28166",
            "queryParameters": null
        },
        {
            "name": "addStar to ZmlsbXM6Mg==",
            "content": "mutation AddStar($filmId: String) {\n    addStar(filmId: \"ZmlsbXM6Mg==\") {\n        id\n        title\n        episodeID\n        director\n        starCount\n        rating\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-addStar",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28169",
            "responseId": "61c09bfb14561b578ad28168",
            "queryParameters": null
        },
        {
            "name": "addReview to ZmlsbXM6Mg==",
            "content": "mutation AddReview($filmId: String, $review: Review) {\n    addReview(filmId: \"ZmlsbXM6Mg==\", review: {comment:\"Awesome!\",rating:5}) {\n        id\n        title\n        episodeID\n        director\n        starCount\n        rating\n    }\n}\n",
            "operationId": "61a8fb5ce0de790a9fc15e10-addReview",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad2816b",
            "responseId": "61c09bfb14561b578ad2816a",
            "queryParameters": null
        }
    ],
    "responses": [
        {
            "name": "film ZmlsbXM6MQ==",
            "content": "{\n  \"data\": {\n    \"film\": {\n        \"id\": \"ZmlsbXM6MQ==\",\n        \"title\": \"A New Hope\",\n        \"episodeID\": 4,\n        \"director\": \"George Lucas\",\n        \"starCount\": 432,\n        \"rating\": 4.3\n    }\n  }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-film",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28164",
            "status": "200",
            "mediaType": "application/json",
            "dispatchCriteria": "?id=ZmlsbXM6MQ==",
            "fault": false
        },
        {
            "name": "film ZmlsbXM6Mg==",
            "content": "{\n    \"data\": {\n        \"film\": {\n            \"id\": \"ZmlsbXM6Mg==\",\n            \"title\": \"The Empire Strikes Back\",\n            \"episodeID\": 5,\n            \"director\": \"Irvin Kershner\",\n            \"starCount\": 433,\n            \"rating\": 4.3\n        }\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-film",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28166",
            "status": "200",
            "mediaType": "application/json",
            "dispatchCriteria": "?id=ZmlsbXM6Mg==",
            "fault": false
        },
        {
            "name": "allFilms",
            "content": "{\n  \"data\": {\n    \"allFilms\": {\n      \"films\": [\n        {\n          \"id\": \"ZmlsbXM6MQ==\",\n          \"title\": \"A New Hope\",\n          \"episodeID\": 4,\n          \"director\": \"George Lucas\",\n          \"starCount\": 432,\n          \"rating\": 4.3\n        },\n        {\n          \"id\": \"ZmlsbXM6Mg==\",\n          \"title\": \"The Empire Strikes Back\",\n          \"episodeID\": 5,\n          \"director\": \"Irvin Kershner\",\n          \"starCount\": 433,\n          \"rating\": 4.3\n        },\n        {\n          \"id\": \"ZmlsbXM6Mw==\",\n          \"title\": \"Return of the Jedi\",\n          \"episodeID\": 6,\n          \"director\": \"Richard Marquand\",\n          \"starCount\": 434,\n          \"rating\": 4.3\n        },\n        {\n          \"id\": \"ZmlsbXM6NA==\",\n          \"title\": \"The Phantom Menace\",\n          \"episodeID\": 1,\n          \"director\": \"George Lucas\",\n          \"starCount\": 252,\n          \"rating\": 3.2\n        },\n        {\n          \"id\": \"ZmlsbXM6NQ==\",\n          \"title\": \"Attack of the Clones\",\n          \"episodeID\": 2,\n          \"director\": \"George Lucas\",\n          \"starCount\": 320,\n          \"rating\": 3.9\n        },\n        {\n          \"id\": \"ZmlsbXM6Ng==\",\n          \"title\": \"Revenge of the Sith\",\n          \"episodeID\": 3,\n          \"director\": \"George Lucas\",\n          \"starCount\": 410,\n          \"rating\": 4.1\n        }\n      ]\n    }\n  }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-allFilms",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28162",
            "status": "200",
            "mediaType": "application/json",
            "dispatchCriteria": null,
            "fault": false
        },
        {
            "name": "addStar to ZmlsbXM6Mg==",
            "content": "{\n    \"data\": {\n        \"addStar\": {\n            \"id\": \"ZmlsbXM6Mg==\",\n            \"title\": \"The Empire Strikes Back\",\n            \"episodeID\": 5,\n            \"director\": \"Irvin Kershner\",\n            \"starCount\": 434,\n            \"rating\": 4.3\n        }\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-addStar",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad28168",
            "status": "200",
            "mediaType": "application/json",
            "dispatchCriteria": "?filmId=ZmlsbXM6Mg==",
            "fault": false
        },
        {
            "name": "addReview to ZmlsbXM6Mg==",
            "content": "{\n    \"data\": {\n        \"addReview\": {\n            \"id\": \"ZmlsbXM6Mg==\",\n            \"title\": \"The Empire Strikes Back\",\n            \"episodeID\": 5,\n            \"director\": \"Irvin Kershner\",\n            \"starCount\": 433,\n            \"rating\": 4.4\n        }\n    }\n}",
            "operationId": "61a8fb5ce0de790a9fc15e10-addReview",
            "testCaseId": null,
            "sourceArtifact": "films-postman.json",
            "headers": null,
            "id": "61c09bfb14561b578ad2816a",
            "status": "200",
            "mediaType": "application/json",
            "dispatchCriteria": null,
            "fault": false
        }
    ]
}

I’m gonna try on a Kubernetes cluster with Microcks 1.5.0 installed with Helm as well.

1reaction
lbroudouxcommented, Mar 24, 2022

Hi @matteocastellotti

I’m going to check this. I’ll use:

Version 1.5.1-SNAPSHOT Build timestamp 2022-03-24T06:35:18Z

Will let you know my findings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing Services & APIs | Microcks.io
This page will take you through a complete explanation of supported formats and the import mechanisms present in Microcks. Supported formats. As ...
Read more >
API Mocking and Testing | Microcks.io
Continuous Integration. Mock and test continuously. Integrate seemlessly in your continuous build or pipelines. We provide plugins, CLIs or containers for you ...
Read more >
Getting started | Microcks.io
In your terminal issue the following commands: Clone this repository. git clone https://github.com/microcks/microcks.git. Change to the install folder.
Read more >
Using exposed mocks | Microcks.io
Find the Mock URL and the Http method of the corresponding operation, look at the instantiated URI for each example request/response pair, copy...
Read more >
Installing | Microcks.io
In your terminal issue the following commands: Clone this repository. git clone https://github.com/microcks/microcks.git Change to the install folder cd ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found