1

I have set up the Rust Rocket web framework and I have been able to make use of the official Elasticsearch Rust crate to set up a client and get documents from the elasticsearch index. However while looking at this example https://github.com/davidpdrsn/graphql-app-example I noticed that the GraphQL that is hooked up to Postgres here uses the .attach() method supplied by rocket. I tried to do the same with my elasticsearch client by implementing the Fairing trait on the elasticsearch client but it wasn't possible. I received the following error: error[E0117]: only traits defined in the current crate can be implemented for arbitrary types. This makes sense so I tried to wrap the type and then implement the Fairing trait on it and got a separate error: (dyn elasticsearch::http::transport::ConnectionPool + 'static) cannot be sent between threads safely. This also makes sense since the official elasticsearch client for RUST is async.

So my question is this: can elasticsearch, graphql and Rust Rocket be set up to work together? And if they can work together, are there any good working examples? I did a lot of googling and I searched through some repos on github and was unable to find a solution.

zalir
  • 11
  • 1