How do I remove "query" from the beginning of the query?
tylers-username opened this issue · 1 comments
tylers-username commented
I'm trying to us the Weaviate Get{}
function but new Query()
and new QueryBuilder()
prefix the query with query
.
My Code:
# NOTE: The `dd()` and `collection()` functions are Laravel methods.
$classQueryBuilder = new Query($className);
$nearTextArgs = [
'concepts' => [$search],
'distance' => 0.3,
'moveTo' => [
'concepts' => ["troubleshoot", "help", "support"],
'force' => 0.45
]
];
$cleanNearTextString = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', collect($nearTextArgs)->toJson());
$query = $classQueryBuilder->setOperationName('Get')
->setArguments(['nearText' => new RawObject($cleanNearTextString)])
->setSelectionSet([
'title',
'content',
'url',
(new Query('_additional'))->setSelectionSet([
'id',
'distance',
'certainty',
'vector',
])
]);
dd((string) $query);
The actual output:
query Get {
KnowledgeBase(
nearText: {
concepts:["How do i use mysql"],
distance:0.3,
moveTo:{
concepts: ["troubleshoot","help","support"],
force:0.45
}
}
) {
title
content
url
_additional {
id
distance
certainty
vector
}
}
}
The expected output:
{
Get {
KnowledgeBase(
nearText: {
concepts:["How do i use mysql"],
distance:0.3,
moveTo:{
concepts: ["troubleshoot","help","support"],
force:0.45
}
}
) {
title
content
url
_additional {
id
distance
certainty
vector
}
}
}
}
tylers-username commented
Ah, looks like I'm wrong. Sorry, new to GraphQL.
The actual expected output would be query { Get { ... } }
. I was missing the outer brackets.