Skip to content

Commit

Permalink
docs(#200): fix GQL/REST write several examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashornych committed Dec 11, 2023
1 parent 311cae3 commit 23f7f17
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 137 deletions.
26 changes: 13 additions & 13 deletions documentation/user/en/get-started/create-first-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ that forms a tree, product is enabled to have prices:
Now you can use the [system API](/documentation/user/en/use/connectors/graphql.md#graphql-api-instances) via the URL
`https://your-server:5555/gql/system` to create a new empty catalog:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/complete-startup.java" langSpecificTabOnly local>

[Example of creating empty catalog](/documentation/user/en/get-started/example/define-catalog.graphql)
</SourceCodeTabs>
Expand All @@ -77,7 +77,7 @@ modifying its schema via the [catalog schema API](/documentation/user/en/use/con
contains some attributes (either localized or non-localized), category is marked as a hierarchical entity that forms
a tree, product is enabled to have prices:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/complete-startup.java,/documentation/user/en/get-started/example/define-test-catalog.java" langSpecificTabOnly local>

[Example of creating empty catalog](/documentation/user/en/get-started/example/define-schema-for-catalog.graphql)
</SourceCodeTabs>
Expand All @@ -91,7 +91,7 @@ a tree, product is enabled to have prices:
Now you can use the [system API](/documentation/user/en/use/connectors/rest.md#rest-api-instances) via the URL
`https://your-server:5555/rest/system/catalogs` to create a new empty catalog:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/complete-startup.java" langSpecificTabOnly local>

[Example of creating empty catalog](/documentation/user/en/get-started/example/define-catalog.rest)
</SourceCodeTabs>
Expand All @@ -102,7 +102,7 @@ modifying its schema via the [catalog schema API](/documentation/user/en/use/con
contains some attributes (either localized or non-localized), category is marked as a hierarchical entity that forms
a tree, product is enabled to have prices:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/complete-startup.java,/documentation/user/en/get-started/example/define-test-catalog.java" langSpecificTabOnly local>

[Example of creating empty catalog](/documentation/user/en/get-started/example/define-schema-for-catalog.rest)
</SourceCodeTabs>
Expand All @@ -115,7 +115,7 @@ a tree, product is enabled to have prices:

Once the catalog is created and the schema is known, you can insert a first entity to the catalog:

<SourceCodeTabs requires="/documentation/user/en/get-started/example/complete-startup.java,/documentation/user/en/get-started/example/define-test-catalog.java" langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/define-catalog-with-schema.java" langSpecificTabOnly local>

[Example of inserting an entity](/documentation/user/en/get-started/example/create-first-entity.java)
</SourceCodeTabs>
Expand All @@ -142,7 +142,7 @@ Once the catalog is created and the schema is known, you can insert a first enti
[catalog data API](/documentation/user/en/use/connectors/graphql.md#graphql-api-instances) at the
`https://your-server:5555/gql/test-catalog` URL:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/define-catalog-with-schema.java" langSpecificTabOnly local>

[Example of inserting an entity](/documentation/user/en/get-started/example/create-first-entity.graphql)
</SourceCodeTabs>
Expand Down Expand Up @@ -170,7 +170,7 @@ Once the catalog is created and the schema is known, you can insert a first enti
[catalog data API](/documentation/user/en/use/connectors/rest.md#rest-api-instances) at the URL
`https://your-server:5555/rest/test-catalog/brand`:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/define-catalog-with-schema.java" langSpecificTabOnly local>

[Example of inserting an entity](/documentation/user/en/get-started/example/create-first-entity.rest)
</SourceCodeTabs>
Expand All @@ -197,7 +197,7 @@ as mentioned above.

Once you learn the basics, you can create a small dataset to work with:

<SourceCodeTabs requires="/documentation/user/en/get-started/example/complete-startup.java,/documentation/user/en/get-started/example/define-test-catalog.java" langSpecificTabOnly>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/define-catalog-with-schema.java" langSpecificTabOnly local>

[Example of creating a small dataset](/documentation/user/en/get-started/example/create-small-dataset.java)
</SourceCodeTabs>
Expand Down Expand Up @@ -260,7 +260,7 @@ For more information, see the [write API description](../use/api/write-data.md#u

Updating an entity is similar to creating a new entity:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/create-small-dataset.java" langSpecificTabOnly local>

[Example of listing entities](/documentation/user/en/get-started/example/update-entity.graphql)
</SourceCodeTabs>
Expand All @@ -277,7 +277,7 @@ For more information, see the [write API description](../use/api/write-data.md#u

Updating an entity is similar to creating a new entity:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/create-small-dataset.java" langSpecificTabOnly local>

[Example of listing entities](/documentation/user/en/get-started/example/update-entity.rest)
</SourceCodeTabs>
Expand Down Expand Up @@ -349,7 +349,7 @@ For more complex examples and explanations, see the [write API chapter](../use/a
You can issue a query that removes all the entities that match the query using the same catalog data API that you
would use to insert, update or retrieve entities:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/create-small-dataset.java" langSpecificTabOnly local>

[Example of deleting entity by query](/documentation/user/en/get-started/example/delete-entity-by-query.graphql)
</SourceCodeTabs>
Expand All @@ -363,15 +363,15 @@ For more complex examples and explanations, see the [write API chapter](../use/a

You can delete entity by is primary key:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/create-small-dataset.java" langSpecificTabOnly local>

[Example of deleting entity by PK](/documentation/user/en/get-started/example/delete-entity-by-pk.rest)
</SourceCodeTabs>

Or, you can issue a query that removes all the entities that match the query using the same catalog data API that you
would use to insert, update or retrieve entities:

<SourceCodeTabs langSpecificTabOnly local>
<SourceCodeTabs requires="/documentation/user/en/get-started/example/create-small-dataset.java" langSpecificTabOnly local>

[Example of deleting entity by query](/documentation/user/en/get-started/example/delete-entity-by-query.rest)
</SourceCodeTabs>
Expand Down
25 changes: 24 additions & 1 deletion documentation/user/en/get-started/example/read-entity-by-pk.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
/*
*
* _ _ ____ ____
* _____ _(_) |_ __ _| _ \| __ )
* / _ \ \ / / | __/ _` | | | | _ \
* | __/\ V /| | || (_| | |_| | |_) |
* \___| \_/ |_|\__\__,_|____/|____/
*
* Copyright (c) 2023
*
* Licensed under the Business Source License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/FgForrest/evitaDB/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

final String brandNameInEnglish = evita.queryCatalog(
"evita",
session -> {
return session.getEntity("Brand", 1, attributeContent("name"), dataInLocales(Locale.ENGLISH))
return session.getEntity("Brand", 1, attributeContent("name"))
.orElseThrow()
.getAttribute("name");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ mutation {
createAttributeSchemaMutation: {
name: "code",
type: String
unique: true
uniquenessType: UNIQUE_WITHIN_COLLECTION
}
},
{
createAttributeSchemaMutation: {
name: "url"
type: String
unique: true
uniquenessType: UNIQUE_WITHIN_COLLECTION
localized: true
}
},
Expand Down
Loading

0 comments on commit 23f7f17

Please sign in to comment.