OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.14k stars 587 forks source link

GraphQL queries fail when server updates in dev mode #12641

Open k-rtik opened 4 years ago

k-rtik commented 4 years ago

Describe the bug When I update a service class annotated with @GraphQLApi, all queries/mutations (including ones that are unaffected by the change and work before making the update in dev mode) return the following:

{
  "errors": [
    {
      "message": "Server Error",
      "locations": [{...}],
      "path": [...],
      "extensions": {
        "exception": "java.lang.IllegalArgumentException",
        "classification": "DataFetchingException"
      }
    }
  ],
  "data": {...}
}

Even changes like updating a log message cause this error.

The error only happens when a query is ran before updating the server, then running a query after updating the server.

No stack trace present in $WLP_OUTPUT_DIR/messages.log/server console output.

Steps to Reproduce

Case 1.

  1. Start dev mode
  2. Run the query, it returns the right result.
  3. Update service, wait for dev mode to update container
  4. Run the query, it returns an error.

Case 2.

  1. Start dev mode
  2. Update service, wait for dev mode to update container
  3. Run the query, it returns the right result.
  4. Update service, wait for dev mode to update container
  5. Run the query, it returns an error.

Expected behavior

Case 1.

  1. Start dev mode
  2. Run the query, it returns the right result.
  3. Update service, wait for dev mode to update container
  4. Run the query, it should return the right result.

Case 2.

  1. Start dev mode
  2. Update service, wait for dev mode to update container
  3. Run the query, it returns the right result.
  4. Update service, wait for dev mode to update container
  5. Run the query, it should return the right result.

Diagnostic information:

mpGraphQL-1.0 jsp-2.3 jsonb-1.0 json-1.0 cdi-2.0


**Additional context**
I am using `graphiql.html` for manual testing and `io.smallrye.graphql.client.typesafe.api.GraphQlClientBuilder` for integration testing
ericglau commented 4 years ago

This error occurs even without dev mode. For example:

  1. git clone https://github.com/OpenLiberty/sample-mp-graphql
  2. Run mvn clean package liberty:run
  3. Run query
  4. Edit a Java file
  5. In another terminal, run mvn package (or skip this step if your IDE auto-compiles the Java file after step 4)
  6. Run query. The error is returned.
yeekangc commented 4 years ago

FYI, @andymc12.

andymc12 commented 3 years ago

Confirmed with @AustinSeto that this problem still exists in Liberty 20.0.0.11 (I had hoped that the SmallRye GraphQL upgrades might have resolved this issue).

AustinSeto commented 3 years ago

I recently tested this with the GM Candidate build for Liberty 20.0.0.12 - the build 2020-11-11_0736 - after hearing some changes were made.

I seem to get the same error. I started an application (the application in https://github.com/OpenLiberty/draft-guide-graphql-intro/tree/redesign-2) in dev mode, and modified it by adding a System.out.println() call which should not break the application. However, when I made a request through GraphiQL I still got the following error. This error appeared even after I reverted my change.

{
  "errors": [
    {
      "message": "Server Error",
      "locations": [
        {
          "line": 2,
          "column": 12
        }
      ],
      "path": [
        "system",
        "username"
      ],
      "extensions": {
        "exception": "java.lang.IllegalArgumentException",
        "classification": "DataFetchingException",
        "code": "illegal-argument"
      }
    },
    {
      "message": "Server Error",
      "locations": [
        {
          "line": 2,
          "column": 21
        }
      ],
      "path": [
        "system",
        "note"
      ],
      "extensions": {
        "exception": "java.lang.IllegalArgumentException",
        "classification": "DataFetchingException",
        "code": "illegal-argument"
      }
    }
  ],
  "data": null
}
yeekangc commented 3 years ago

@AustinSeto, is what you reported reproducible without dev mode?

@andymc12, not sure if we have an outlook for resolving this issue? This is blocking our work on the MP GraphQL guide.

Cc @gkwan-ibm

AustinSeto commented 3 years ago

@yeekangc Just tested with LMP 3.3.3 to see if any changes in it affected this issue. The issue still occurs in dev mode. I started the app in dev mode, it worked fine, then I added a print statement and dev mode recompiled and then I got the same error as previously.

I try the same with mvn liberty:run. I start the app, see it works fine. I close it, then make my change, then restart it using mvn liberty:run and I do not encounter the error.

The error is not reproducible without dev mode.

yeekangc commented 3 years ago

@ericglau, any thoughts on the latest that Austin reported?

ericglau commented 3 years ago

I still see the error when using the steps in my previous comment with Liberty 20.0.0.12 and liberty:run (note, do not stop the server after making a change to a Java file. Just compile while Liberty is running, as per that comment).

Logs are attached: logs.zip Note that the exception in the FFDC log occurred only on first startup. Also there are warnings with W Could not load service class com.ibm.ws.io.smallrye.graphql.component.GraphQLExtension both on startup and after updating the app.

AustinSeto commented 3 years ago

Currently writing a draft of the MP GraphQL guide that does not require dev mode as a work around, but we would prefer to publish a version of the guide that does use dev mode.

@andymc12 are there any updates regarding this issue?

gkwan-ibm commented 3 years ago

Another case not work

If graphql service not run by loose app (i.e., the common jar packaged into the war), it works fine and no warning.

gkwan-ibm commented 1 year ago

labeled "Needs member attention" because of this guide issue