# Validating Sparql queries

**URL:** <https://community.stardog.com/t/validating-sparql-queries/2185>\
**Category:** Support\
**Created:** [January 9, 2020, 8:15am UTC](https://community.stardog.com/t/validating-sparql-queries/2185 "2020-01-09T08:15:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toni\_Cebrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/toni_cebrian/32/528_2.png) [@Toni\_Cebrian](https://community.stardog.com/u/Toni_Cebrian)\
**Post date:** [January 9, 2020, 8:15am UTC](https://community.stardog.com/t/validating-sparql-queries/2185/1 "2020-01-09T08:15:28Z")

</div>

In our codebase we build some SPARQL programatically by gluing some chunks of text. In order to validate that the SPARQL queries are valid we have some integration tests that check that the queries don't raise any MalformedQuery exception but that requires connectivity to a Stardog instance.

Is there a way to parse and check for syntactic validation of Stardog's SPARQL queries that could allow converting those integration tests to unit tests in Java?

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [January 9, 2020, 3:26pm UTC](https://community.stardog.com/t/validating-sparql-queries/2185/2 "2020-01-09T15:26:43Z")

</div>

You may want to look at `QueryFactory` [Stardog-8.2.0 API](https://www.stardog.com/docs/java/snarl/com/stardog/stark/query/queryfactory) . It says that parsing _could_ be done lazily but it's not clear if there's a way to make it do parsing eagerly.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [January 23, 2020, 3:26pm UTC](https://community.stardog.com/t/validating-sparql-queries/2185/3 "2020-01-23T15:26:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
