-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueryType.php
More file actions
66 lines (62 loc) · 2.22 KB
/
Copy pathqueryType.php
File metadata and controls
66 lines (62 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
$parameterType = new ObjectType([
'name' => 'Parameter',
'fields' => [
'parameter' => [
'type' => Type::nonNull(Type::string()),
'description' => 'URL parameter'
],
'key' => [
'type' => Type::string(),
'description' => 'The key that is used in the Webtrek V3/4 instance or in the object of the wts.push argument'
],
'descDe' => [
'type' => Type::string(),
'description' => 'German description'
],
'frontendDe' => [
'type' => Type::string(),
'description' => 'German description of where to find in the frontend'
],
'descEn' => [
'type' => Type::string(),
'description' => 'English description'
],
'frontendEn' => [
'type' => Type::string(),
'description' => 'English description of where to find in the frontend'
],
'type' => [
'type' => Type::nonNull(Type::string()),
'description' => 'General Type which can be used to filter'
],
]
]);
$queryType = new ObjectType([
'name' => 'Query',
'fields' => [
'parameter' => [
'type' => Type::listOf($parameterType),
'description' => 'URL parameter in trackrequests, how to set them, where to find the tracked data in frontend',
'args' => [
'type' => Type::string(),
],
'resolve' => function ($root, $args) {
$rows = array_map(function($row) { return str_getcsv($row, '|'); }, file('./dataSource/parameterData.csv'));
$header = array_shift($rows);
$parameter_data = array();
foreach($rows as $row) {
if(array_key_exists("type", $args)) {
if($args['type'] == $row[6])
$parameter_data[] = array_combine($header, $row);
} else
$parameter_data[] = array_combine($header, $row);
}
return $parameter_data;
}
]
],
]);
?>