Accessing GraphQL subscription via Java client


I am trying to access and more specifically GraphQL using a Java client.

What I want to do is to constantly have an active subscriber of i.e. commitCreated subscription. I tried using the CURL that the playground provides, but it is executed only once, it provides a “null” value and then stops. The same happens using a POST request which has as a body the subscription. Also, I’ve researched the possible GraphQL libraries to access such information but most of them lack in documentation or are oriented for android development, so the structure is different than expected. Another fact that I noticed is that even in the playground, the subscription stops in approximately a minute.

Could you please help me find a solution on that?

Thank you in advance.

Hello @Maria_Rousi and welcome to the forum!

I’ll check with the team and get back to you if any of us has experience with this, but so far none of us has called the API from Java…

What Java libraries have you tried? I did a quick search and found this one specifically for android that has quite a few examples: 11. Write your first subscription - Client (Android) - Apollo GraphQL Docs

I’d be also super interested to hear what you’re building, and if you get a chance you can always Introduce yourself 🙆 !

There are quite a few frameworks that let you build Android apps in javascript, if that’s an option we’d definitely be able to assist you more in working with the API!

Hello @teocomi ,

Thank you for the quick answer.

I am a developer on PrismArch project.

This library is oriented in android development and not a plain java project (which is my target). The syntax in the two cases is different, so I couldn’t use this library as it is like it is implemented in a completely different language.

I have tried various approaches that I found, none of them seems to be the case though. It seems that most of them connect to a Speckle database that has been deployed locally with a custom schema. What I haven’t found is a full example in Java that connects to and executes a subscription query. A few examples that I found (but didn’t work) are provided below:

1 Like

Hi @Maria_Rousi, I’m afraid no one from our team has any real Java experience… what I remember is only stuff from high school when i was making funky cubes spin around in processing.

If you share your wip code on a repo, we could poke and try build and help a bit more. Sorry to disappoint otherwise. Java’s not seen much in AEC, so we’re short of know-how/love for it in speckle-land…