override the `/graphql` endpoint using dropwizard and kotlin - kotlin

I am using dropwizard and kotlin to implement the graphql endpoints. My project uses the code first approach to generate the schema.
The code runs fine but everytime I open the endpoint http://localhost:PORT- the by default playground url displays as http://localhost:PORT/graphql. I want to update this to http://localhost:PORT/api/graphql.
I tried to override the run method of GraphqlBundle class as mentioned here - https://github.com/smoketurner/dropwizard-graphql
But, still no luck. Can someone please help in this.

Related

How can I build an Agroal connection at runtime with native support

I'm trying to build a dynamic database connection via Agroal inside a native image. It's not possible to use the default config params because I don't know the connection params at compile time. Is that even possible right now?
The connection is built like this at runtime:
AgroalDataSource.from(
AgroalDataSourceConfigurationSupplier()
...)
I'm currently seeing this error:
Class io.agroal.pool.ConnectionHandler[] is instantiated reflectively but was never registered.
Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection
The installed features include: [agroal, cdi, jdbc-h2, jdbc-mysql, jdbc-postgresql, kotlin, narayana-jta, resteasy, resteasy-jackson]
It runs fine on the JVM, but not using Graal. It feels like it should be possible and I'm probably missing something here. I was hoping adding agraol extension would be sufficient but obviously isn't picked up correctly.
The current situation is that we configure Agroal for native images only if you have a datasource defined using Quarkus configuration.
Thus for your use case, for now, you will have to do what we do automatically manually. What we do being registering some classes for reflection and including some resources in the native image.
See https://github.com/quarkusio/quarkus/blob/master/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java#L91 and https://quarkus.io/guides/writing-native-applications-tips#using-a-configuration-file.
Obviously, that's not ideal. Could you open an issue on our GitHub so that we can discuss it internally and see if we should/can improve the situation?
In the end, you would still need some reflection registration for your JDBC driver though.

Grails Dashboard says I have no Services

In the process of trying to troubleshoot my Grails SQL Issue, I just realized that the default Grails Splash page says I have 0 Services. I figured this is a separate issue so I made a new question. I'm on Grails 3.3.9. See attached picture. I'm using default scaffolded code here so my index page is calling my list method in the Service. What am I missing here? Service below (excuse my ignorance, I'm coming from Grails 2.3.11):
package TSTSupport
import grails.gorm.services.Service
import grails.gorm.transactions.Transactional
#Service(TST_Customer)
#Transactional
interface TST_CustomerService {
TST_Customer get(Serializable id)
List<TST_Customer> list(Map args)
Long count()
void delete(Serializable id)
TST_Customer save(TST_Customer TST_Customer)
}
Thanks to #JeffScottBrown, I realized that in Grails 3.3.9, the generate-all command creates a gorm data service which is different from a regular service (which is why Grails says I have 0 services). Using create-service is the way to go if you want the actual dashboard to recognize your services.

Restler3 Integration with Grafana SimpleJson plugin

I'm trying to make an integration with Grafana, using Simple-Json databse plugin.
I configured the integration but needed some help on the Restler part.
I created a class (Compliance) in an instance of Restler that will fetch information from a database. I am accessing this class through the url http://ws.server.com.br/service/inventory/index.php/compliance
This is working fine, however the SimpleJson plugin needs to implement the following endpoints to work:
/
/search
/query
/annotations
The endpoint / is returning correctly, however I am having problems with the other endpoints.
Debugging the requests that are made in the webserver, I see that grafana is trying to make a post in the url http://ws.server.com.br/service/inventory/index.php/compliance/search, but error 405 occurs (method not allowed).
I know I need to implement a function post in this URL, but if I create this function in my class Compliance it is referring to the class itself, not the search method.
Does anyone have any idea how to do this?
405 means the URL is available but not for the specific method that is used which I assume is POST in this case, I guess your class us Compliance and method name is search. If you add a method named postSearch it will receive the grafana request

atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set

This is what I get when I run atlas-create-jira-plugin followed by atlas-create-jira-plugin-module selecting option 1: Component Import.
The problem is that all tutorial examples appear to have plugin descriptor generated by old SDK version (that won't deploy with newer versions of SDK/Jira at all), which do not feature Atlassian-Plugin-Key, so I can't find my way to import a component.
I'm using SDK 6.2.3 and Jira 7.1.1.
Any hint - how to get this sorted out?
anonymous is correct. The old way of doing things was to to put the <component-import> tag in your atlassian-plugin.xml. The new way and also recommended is to use Atlassian Spring Scanner. When you create your add-on using atlas-jira-create-plugin and your pom.xml has the <Atlassian-Plugin-Key> tag and the dependencies atlassian-spring-scanner-annotation and atlassian-spring-scanner-runtime then you are using the new way.
If you have both the dependencies, you are using Atlassian Spring Scanner version 1.x. If you only have atlassian-spring-scanner-annotation then you are using version 2.x.
You don't have to omit/comment out Atlassian-Plugin-Key in your pom.xml and you don't have to put component-import in your atlassian-plugin.xml.
For example, you want to add licensing for your add-on and need to import the component PluginLicenseManager. You just go straight to the code and your constructor might look like this:
#Autowired
public MyMacro(#ComponentImport PluginLicenseManager licenseManager) {
this.licenseManager = licenseManager;
}
And your class like this:
#Scanned
public class MyMacro implements Macro {
If memory serves me right, be sure to check for null because sometimes Atlassian Spring Scanner can't inject a component. I think on version 1, writing an #EventListener, it could not inject a ConversionContext. But when writing a Macro, it was able to inject a ConversionContext.
According to
https://bitbucket.org/atlassian/atlassian-spring-scanner
component-import is not needed. You can replace it by #ComponentImport annotation in your Java.
Found answer here: https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins
It looks like I've somehow been missing that Atlassian-Plugin-Key can be omitted, and it must be done when you need to import components.
This key just tells spring not to 'transform' plugin's Spring configuration, which must happen as part of components import process..

Autofac request lifetime scope always null using Web Api 2.2 integration (3.4)

I'm using the autofac web api 2.2 integration (version 3.4) and I'm debugging one of my controllers. It seems like the request lifetime scope is always null when I try the following from any point where I'd expect there to be an active request:
var x = (AutofacWebApiDependencyResolver) GlobalConfiguration.Configuration.DependencyResolver;
x.GetRequestLifetimeScope(); // always null
Is this expected behavior? I'm a bit confused because it looks like all of my components are resolved at 'root' which, according to the documentation is bad. I was expecting it to automatically put it into a request scope when I register using InstancePerRequest(). It seems like:
AutofacWebApiDependencyResolver.BeginScope()
never happens.
I could post more sample code, but I've reproduced it following the quick start guide with very basic controllers, so I suspect it's more of a flaw in my logic above and was hoping someone could point it out. Thanks!
I had the same problem and my issue was that I copied my autofac configuration from a MVC project and was registering my dependencies with InstancePerRequest. When I changed that to InstancePerDependency instead it solved the problem and GetRequestLifetimeScope was working.
builder.RegisterType<X>().As<IX>().InstancePerDependency();
In action method, you can get the request scope by
var scope = Request.GetDependencyScope();