11<?php namespace ProcessWire ;
22
3+ use \ProcessWire \GraphQL \Type \InterfaceType \PageInterfaceType ;
4+
5+ require_once $ this ->config ->paths ->site . 'modules/ProcessGraphQL/vendor/autoload.php ' ;
6+
37class ProcessGraphQLConfig extends Moduleconfig {
48
59 public function getDefaults ()
@@ -9,6 +13,14 @@ public function getDefaults()
913 'debug ' => false ,
1014 'legalTemplates ' => [],
1115 'legalFields ' => [],
16+ 'legalPageFields ' => [
17+ 'created ' ,
18+ 'modified ' ,
19+ 'url ' ,
20+ 'id ' ,
21+ 'name ' ,
22+ 'httpUrl ' ,
23+ ],
1224 'fullWidthGraphiql ' => false ,
1325 );
1426 }
@@ -17,6 +29,7 @@ public function getInputFields()
1729 {
1830 $ inputfields = parent ::getInputFields ();
1931
32+ // maxLimit
2033 $ f = $ this ->modules ->get ('InputfieldInteger ' );
2134 $ f ->attr ('name ' , 'maxLimit ' );
2235 $ f ->label = 'Max Limit ' ;
@@ -25,43 +38,51 @@ public function getInputFields()
2538 $ f ->columnWidth = 35 ;
2639 $ inputfields ->add ($ f );
2740
28- $ f = $ this ->modules ->get ('InputfieldCheckbox ' );
29- $ f ->attr ('name ' , 'debug ' );
30- $ f ->label = 'Debug ' ;
31- $ f ->description = 'When you turn on debug mode some extra fields will be available. Like `dbQueryCount` etc. ' ;
32- $ f ->columnWidth = 35 ;
33- $ inputfields ->add ($ f );
34-
41+ // GraphiQL full width
3542 $ f = $ this ->modules ->get ('InputfieldCheckbox ' );
3643 $ f ->attr ('name ' , 'fullWidthGraphiQL ' );
3744 $ f ->label = 'Full width GraphiQL ' ;
3845 $ f ->description = 'Check this if you want GraphiQL on the backend to stretch to full width. ' ;
3946 $ f ->columnWidth = 30 ;
4047 $ inputfields ->add ($ f );
4148
49+ // legalTemplates
4250 $ f = $ this ->modules ->get ('InputfieldCheckboxes ' );
43- foreach (\ProcessWire \wire ('templates ' ) as $ template ) {
44- $ f ->addOption ($ template ->name , $ template ->flags & Template::flagSystem ? "{$ template ->name } (system) " : $ template ->name );
45- }
4651 $ f ->optionColumns = 4 ;
4752 $ f ->attr ('name ' , 'legalTemplates ' );
4853 $ f ->label = 'Legal Templates ' ;
4954 $ f ->description = 'The pages with the templates that you select below will be available via your GraphQL api. ' ;
50- $ f ->notes = 'Please be careful with what you are exposing to the public. Choosing templates marked as system can lead to security issues. ' ;
55+ $ f ->notes = 'Please be careful with what you are exposing to the public. Choosing templates marked as `system` can lead to security vulnerabilities. ' ;
56+ foreach (\ProcessWire \wire ('templates ' ) as $ template ) {
57+ $ f ->addOption ($ template ->name , $ template ->flags & Template::flagSystem ? "{$ template ->name } `(system)` " : $ template ->name );
58+ }
5159 $ inputfields ->add ($ f );
5260
61+ // legalFields
5362 $ f = $ this ->modules ->get ('InputfieldCheckboxes ' );
54- foreach (\ProcessWire \wire ('fields ' )->find ("name!=pass " ) as $ field ) {
63+ $ f ->optionColumns = 4 ;
64+ $ f ->attr ('name ' , 'legalFields ' );
65+ $ f ->label = 'Legal Fields ' ;
66+ $ f ->description = 'The fields that you select below will be available via your GraphQL api. ' ;
67+ $ f ->notes = 'Please be careful with what you are exposing to the public. Choosing fields marked as `system` can to lead security vulnerabilities. ' ;
68+ foreach (\ProcessWire \wire ('fields ' )->find ("name!=pass " ) as $ field ) {
5569 if ($ field ->type instanceof FieldtypeFieldsetOpen) continue ;
5670 if ($ field ->type instanceof FieldtypeFieldsetClose) continue ;
5771 if ($ field ->type instanceof FieldtypeFieldsetTabOpen) continue ;
58- $ f ->addOption ($ field ->name , $ field ->flags & Field::flagSystem ? "{$ field ->name } (system) " : $ field ->name );
72+ $ f ->addOption ($ field ->name , $ field ->flags & Field::flagSystem ? "{$ field ->name } ` (system)` " : $ field ->name );
5973 }
74+ $ inputfields ->add ($ f );
75+
76+ // legalPageFields
77+ $ f = $ this ->modules ->get ('InputfieldCheckboxes ' );
6078 $ f ->optionColumns = 4 ;
61- $ f ->attr ('name ' , 'legalFields ' );
62- $ f ->label = 'Legal Fields ' ;
63- $ f ->description = 'The fields that you select below will be available via your GraphQL api. ' ;
64- $ f ->notes = 'Please be careful with what you are exposing to the public. Choosing fields marked as system can to lead security issues. ' ;
79+ $ f ->attr ('name ' , 'legalPageFields ' );
80+ $ f ->label = 'Legal Page Fields ' ;
81+ $ f ->description = 'Choose which built in page fields you wish to be available via GraphQL api. ' ;
82+ $ f ->notes = 'Be careful with fields like `parents` & `children` that will allow user to construct deeply nested queries that might be very expensive for your server to fulfill. ' ;
83+ foreach (PageInterfaceType::getPageFields () as $ fieldName => $ fieldClassName ) {
84+ $ f ->addOption ($ fieldName );
85+ }
6586 $ inputfields ->add ($ f );
6687
6788 return $ inputfields ;
0 commit comments