Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
subscription {
bookCreated {
id
name
}
}
11 changes: 11 additions & 0 deletions example-project/GraphQL/Book created subscription.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"details": {},
"requests": [
{
"location": "Book created subscription-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1"
}
6 changes: 6 additions & 0 deletions example-project/GraphQL/Create book-request.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mutation {
createBook(name: "{{ faker.commerce.product_name }}") {
id
name
}
}
11 changes: 11 additions & 0 deletions example-project/GraphQL/Create book.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"details": {},
"requests": [
{
"location": "Create book-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1"
}
3 changes: 3 additions & 0 deletions example-project/GraphQL/Delete book-request.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutation {
deleteBook(id: 1)
}
11 changes: 11 additions & 0 deletions example-project/GraphQL/Delete book.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"details": {},
"requests": [
{
"location": "Delete book-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1"
}
6 changes: 6 additions & 0 deletions example-project/GraphQL/Get book-request.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query getBook($bookId: Int = 1) {
book(id: $bookId) {
id
name
}
}
3 changes: 3 additions & 0 deletions example-project/GraphQL/Get book-variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bookId": 2
}
15 changes: 15 additions & 0 deletions example-project/GraphQL/Get book.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"details": {
"variables": {
"src": "Get book-variables.json"
}
},
"requests": [
{
"location": "Get book-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1"
}
10 changes: 10 additions & 0 deletions example-project/GraphQL/Get books-request.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query {
books {
id
name
sales {
date
quantity
}
}
}
11 changes: 11 additions & 0 deletions example-project/GraphQL/Get books.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"details": {},
"requests": [
{
"location": "Get books-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1"
}
5 changes: 5 additions & 0 deletions example-project/GraphQL/Update book-request.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutation {
updateBook(id: 1, name: "How to get started with Kreya") {
name
}
}
11 changes: 11 additions & 0 deletions example-project/GraphQL/Update book.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"details": {},
"requests": [
{
"location": "Update book-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1"
}
2 changes: 2 additions & 0 deletions example-project/Kreya features/Script/Simple script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
await kreya.invokeOperation('../../REST/Create book');
await kreya.invokeOperation('../../REST/Delete book');

await kreya.invokeOperation('../../GraphQL/Get book');

await kreya.invokeOperation('../../gRPC/Say hello (unary call)');

await kreya.invokeOperation('../../WebSocket/Echo');
10 changes: 0 additions & 10 deletions example-project/Kreya features/Scripting/File system access.js

This file was deleted.

18 changes: 0 additions & 18 deletions example-project/Kreya features/Scripting/File system access.krop

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query {
books {
id
name
}
}
11 changes: 11 additions & 0 deletions example-project/Kreya features/Scripting/Scripting GraphQL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect } from 'chai';

kreya.graphql.onQueryCompleted(call => {
kreya.trace('The GraphQL query completed.');

kreya.test('Status code', () => expect(call.status.code).to.equal(200));
kreya.test('status is success', () => expect(call.status.isSuccess).to.be.true);

const books = call.response.content.data.books;
kreya.test('First book should have ID 1', () => expect(books[0].id).to.eq(1));
});
16 changes: 16 additions & 0 deletions example-project/Kreya features/Scripting/Scripting GraphQL.krop
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"details": {
"operationType": "query"
},
"requests": [
{
"location": "Scripting GraphQL-request.graphql"
}
],
"operationType": "unary",
"invokerName": "graphql",
"importStreamId": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1",
"script": {
"src": "Scripting GraphQL.js"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":1,"name":"A Tale of Two Cities"}
{ "id": 1, "name": "A Tale of Two Cities" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "{{ vars.testCase.input.name }}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expect } from 'chai';

kreya.grpc.onResponse(msg => {
const testCase = kreya.variables.get('testCase');
kreya.test(testCase.name, () => expect(msg.content.message).to.eql(testCase.expectedOutput.greeting));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"details": {
"methodFqn": "kreya.ExampleService.SayHello"
},
"requests": [
{
"location": "Greet-request.json"
}
],
"operationType": "unary",
"invokerName": "grpc",
"importStreamId": "463869a1-4cf8-470d-871d-c873192881c7",
"script": {
"src": "Greet.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { readFile } from 'fs/promises';

const content = await readFile('./greet-test-data.json', 'utf-8');
const testCases = JSON.parse(content);

for (const testCase of testCases) {
// Set variable consumed by the operation script
kreya.variables.set('testCase', testCase);

// Invoke the operation (relative path to the saved operation in the project tree)
await kreya.invokeOperation('./Greet');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"src": "GreetTest.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"name": "Regular",
"input": {
"name": "Peter"
},
"expectedOutput": {
"greeting": "Hello Peter"
}
},
{
"name": "Empty Name",
"input": {
"name": ""
},
"expectedOutput": {
"greeting": "Hello "
}
},
{
"name": "Single Character",
"input": {
"name": "A"
},
"expectedOutput": {
"greeting": "Hello A"
}
},
{
"name": "Whitespace Name",
"input": {
"name": " "
},
"expectedOutput": {
"greeting": "Hello "
}
},
{
"name": "Name With Spaces",
"input": {
"name": "John Doe"
},
"expectedOutput": {
"greeting": "Hello John Doe"
}
},
{
"name": "Name With Special Characters",
"input": {
"name": "@lice#123"
},
"expectedOutput": {
"greeting": "Hello @lice#123"
}
},
{
"name": "Unicode Characters",
"input": {
"name": "Élise"
},
"expectedOutput": {
"greeting": "Hello Élise"
}
},
{
"name": "Long Name",
"input": {
"name": "ThisIsAVeryLongNameToTestTheAPIHandling"
},
"expectedOutput": {
"greeting": "Hello ThisIsAVeryLongNameToTestTheAPIHandling"
}
}
]
6 changes: 4 additions & 2 deletions example-project/directory.krpref
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
"key": "info-text",
"value": "i am a default settings header"
}
],
"pathParams": []
]
},
"websocket": {
"endpoint": "{{ env.websocket_endpoint }}"
},
"graphql": {
"endpoint": "{{ env.graphql_endpoint }}"
}
}
}
Expand Down
16 changes: 12 additions & 4 deletions example-project/example-project.krproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"id": "463869a1-4cf8-470d-871d-c873192881c7",
"name": "gRPC server reflection importer",
"importerName": "GrpcServerReflection",
"createMissingOperations": false,
"options": {
"endpoint": "{{ env.grpc_endpoint }}",
"disableServerCertificateValidation": false,
Expand All @@ -16,14 +15,21 @@
"id": "3173a966-56b1-435f-9a60-937058ec6c80",
"name": "REST OpenAPI URL importer",
"importerName": "OpenApiUrlImporter",
"createMissingOperations": false,
"options": {
"url": "{{ env.rest_endpoint }}/swagger/v1/swagger.json",
"disableAutoRedirect": false,
"disableServerCertificateValidation": false,
"disableCookies": false,
"infiniteTimeout": false
}
},
{
"id": "c04aa4e5-9f19-4948-8d71-eb4cb97ea2c1",
"name": "GraphQL Schema introspection importer",
"importerName": "GraphQlSchemaIntrospection",
"options": {
"endpoint": "{{ env.graphql_endpoint }}"
}
}
],
"authConfigs": [
Expand All @@ -41,5 +47,7 @@
"headerPrefix": "Basic "
}
}
]
}
],
"certificates": [],
"proxies": []
}
1 change: 1 addition & 0 deletions example-project/production.krenv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"grpc_endpoint": "https://example-api.kreya.app:9090",
"rest_endpoint": "https://example-api.kreya.app",
"websocket_endpoint": "wss://example-api.kreya.app",
"graphql_endpoint": "https://example-api.kreya.app/graphql",
"basic_auth_password": "production-password"
}
}
Loading