Skip to content

Commit

Permalink
Merge pull request #51 from lukashornych/dev
Browse files Browse the repository at this point in the history
Release: evitaDB don't use kebab-case classifiers in API URLs anymore
  • Loading branch information
lukashornych authored Oct 13, 2023
2 parents 1447814 + 12789e2 commit 4f974cf
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In the future, evitaLab will hopefully also allow data modifications.

You can try out evitaLab with evitaDB demo dataset at [demo.evitadb.io](https://demo.evitadb.io).

<img src="https://raw.githubusercontent.com/lukashornych/evitalab/dev/documentation/assets/img/preview.png"/>
![evitaLab preview](documentation/assets/img/preview.png)

## Features

Expand Down
Binary file modified documentation/assets/img/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ export class EvitaQLQueryExecutor extends QueryExecutor {
}

async executeQuery(dataPointer: DataGridDataPointer, query: string): Promise<QueryResult> {
const urlCatalogName: string = (await this.labService.getCatalogSchema(dataPointer.connection, dataPointer.catalogName))
.nameVariants
.kebabCase

const result: Response = await this.evitaDBClient.queryEntities(dataPointer.connection, urlCatalogName, query)
const result: Response = await this.evitaDBClient.queryEntities(dataPointer.connection, dataPointer.catalogName, query)

return {
entities: result?.recordPage?.data.map((entity: any) => this.flattenEntity(entity)) || [],
Expand Down
10 changes: 1 addition & 9 deletions src/services/editor/data-grid-console/graphql-query-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ export class GraphQLQueryExecutor extends QueryExecutor {
}

async executeQuery(dataPointer: DataGridDataPointer, query: string): Promise<QueryResult> {
const urlCatalogName: string = (await this.labService.getCatalogSchema(dataPointer.connection, dataPointer.catalogName))
.nameVariants
.kebabCase

const result = await this.graphQLClient.fetch(
dataPointer.connection,
`${urlCatalogName}`,
query
)
const result = await this.graphQLClient.fetch(dataPointer.connection, dataPointer.catalogName, query)
if (result.errors) {
throw new QueryError(dataPointer.connection, result.errors)
}
Expand Down
6 changes: 1 addition & 5 deletions src/services/editor/evitaql-console.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ export class EvitaQLConsoleService {
*/
// todo lho variables
async executeEvitaQLQuery(dataPointer: EvitaQLDataPointer, query: string, variables?: object): Promise<string> {
const urlCatalogName: string = (await this.labService.getCatalogSchema(dataPointer.connection, dataPointer.catalogName))
.nameVariants
.kebabCase

let result: any
try {
result = await this.evitaDBClient.queryEntities(dataPointer.connection, urlCatalogName, query)
result = await this.evitaDBClient.queryEntities(dataPointer.connection, dataPointer.catalogName, query)
} catch (e: any) {
if (e.name === 'QueryError') {
result = e.error
Expand Down
8 changes: 2 additions & 6 deletions src/services/editor/graphql-console.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ export class GraphQLConsoleService {
if (instancePointer.instanceType === GraphQLInstanceType.SYSTEM) {
path = 'system'
} else {
const urlCatalogName: string = (await this.labService.getCatalogSchema(instancePointer.connection, instancePointer.catalogName))
.nameVariants
.kebabCase

switch (instancePointer.instanceType) {
case GraphQLInstanceType.DATA:
path = urlCatalogName
path = instancePointer.catalogName
break
case GraphQLInstanceType.SCHEMA:
path = `${urlCatalogName}/schema`
path = `${instancePointer.catalogName}/schema`
break
default: throw new UnexpectedError(instancePointer.connection, `Unsupported GraphQL instance type '${instancePointer.instanceType}'.`)
}
Expand Down
8 changes: 4 additions & 4 deletions src/services/evitadb-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class EvitaDBClient extends ApiClient {
/**
* Fetches schema from evitaDB server for specific catalog.
*/
async getCatalogSchema(connection: EvitaDBConnection, urlCatalogName: string): Promise<CatalogSchema> {
async getCatalogSchema(connection: EvitaDBConnection, catalogName: string): Promise<CatalogSchema> {
try {
return await this.httpClient.get(`${connection.labApiUrl}/schema/catalogs/${urlCatalogName}`)
return await this.httpClient.get(`${connection.labApiUrl}/schema/catalogs/${catalogName}`)
.json() as CatalogSchema
} catch (e: any) {
throw this.handleCallError(e, connection)
Expand All @@ -35,10 +35,10 @@ export class EvitaDBClient extends ApiClient {
/**
* Fetches entities with extra results from evitaDB server from specific catalog.
*/
async queryEntities(connection: EvitaDBConnection, urlCatalogName: string, query: string): Promise<Response> {
async queryEntities(connection: EvitaDBConnection, catalogName: string, query: string): Promise<Response> {
try {
return await this.httpClient.post(
`${connection.labApiUrl}/data/catalogs/${urlCatalogName}/collections/query`,
`${connection.labApiUrl}/data/catalogs/${catalogName}/collections/query`,
{
headers: {
'Content-Type': 'application/json'
Expand Down
2 changes: 1 addition & 1 deletion src/services/lab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class LabService {
private async fetchCatalogSchema(connection: EvitaDBConnection, catalogName: string): Promise<CatalogSchema> {
const catalog: Catalog = await this.getCatalog(connection, catalogName)

const fetchedCatalogSchema: CatalogSchema = await this.evitaDBClient.getCatalogSchema(connection, catalog.nameVariants.kebabCase)
const fetchedCatalogSchema: CatalogSchema = await this.evitaDBClient.getCatalogSchema(connection, catalog.name)

this.store.commit(
'lab/putCatalogSchema',
Expand Down
10 changes: 9 additions & 1 deletion src/store/modules/lab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,19 @@ const state = (): LabState => {
preconfiguredConnections.push(new EvitaDBConnection(
'demo',
'Demo',
false,
true,
'https://demo.evitadb.io/lab/api',
'https://demo.evitadb.io:5555/rest',
'https://demo.evitadb.io:5555/gql'
))
preconfiguredConnections.push(new EvitaDBConnection(
'localhost',
'Localhost',
true,
'https://localhost:5555/lab/api',
'https://localhost:5555/rest',
'https://localhost:5555/gql'
))
}

// initialize storage for the current instance
Expand Down

0 comments on commit 4f974cf

Please sign in to comment.