-
Notifications
You must be signed in to change notification settings - Fork 18
Added DKG SPARQL query tool and minor code cleanup #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ing in dev mode, and made some general code cleanup in the plugin-dkg-essentials.
|
|
||
| // Only allow query types supported by the DKG node | ||
| const allowedQueryTypes = ["SELECT", "CONSTRUCT"]; | ||
| if (!allowedQueryTypes.includes(parsed.queryType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could normalize the case here to make sure queryTyoe is always in uppercase. So something like this:
if (!allowedQueryTypes.includes(parsed.queryType?.toUpperCase()))
| } | ||
|
|
||
| // Use validated query type | ||
| const queryType = validation.queryType || "SELECT"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if query passes validation, queryType should always be set so this fallback might hide potential bugs
| const queryResult = await ctx.dkg.graph.query(query, queryType); | ||
|
|
||
| const resultText = JSON.stringify(queryResult, null, 2); | ||
|
|
||
| return { | ||
| content: [ | ||
| { | ||
| type: "text", | ||
| text: `✅ Query executed successfully\n\n**Results:**\n\`\`\`json\n${resultText}\n\`\`\``, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use JSON.stringify when a CONSTRUCT query is called since construct returns a raw string of N-triples?
Added DKG SPARQL query tool to plugin-dkg-essentials, fixed the concurrency issue when running in dev mode, and made some general code cleanup in the plugin-dkg-essentials.