forked from stashapp/stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve client-side graphql scalar types (stashapp#4511)
* Add types to graphql scalars * Upgrade dependencies * Override UI config type * Remove all IUIConfig casts * Add tableColumns to IUIConfig * Add BoolMap type, set strictScalars * Add PluginConfigMap * Replace any with unknown * Add SavedObjectFilter and SavedUIOptions * Remove unused items from CriterionType
- Loading branch information
1 parent
f8098e9
commit 11059d3
Showing
121 changed files
with
890 additions
and
1,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
"Log entries" | ||
scalar Time | ||
|
||
enum LogLevel { | ||
Trace | ||
Debug | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
scalar Upload | ||
|
||
input GenerateMetadataInput { | ||
covers: Boolean | ||
sprites: Boolean | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
"An RFC3339 timestamp" | ||
scalar Time | ||
|
||
""" | ||
Timestamp is a point in time. It is always output as RFC3339-compatible time points. | ||
It can be input as a RFC3339 string, or as "<4h" for "4 hours in the past" or ">5m" | ||
for "5 minutes in the future" | ||
""" | ||
scalar Timestamp | ||
|
||
# generic JSON object | ||
"A String -> Any map" | ||
scalar Map | ||
|
||
# string, boolean map | ||
"A String -> Boolean map" | ||
scalar BoolMap | ||
|
||
"A plugin ID -> Map (String -> Any map) map" | ||
scalar PluginConfigMap | ||
|
||
scalar Any | ||
|
||
scalar Int64 | ||
|
||
"A multipart file upload" | ||
scalar Upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/99designs/gqlgen/graphql" | ||
) | ||
|
||
func MarshalPluginConfigMap(val map[string]map[string]interface{}) graphql.Marshaler { | ||
return graphql.WriterFunc(func(w io.Writer) { | ||
err := json.NewEncoder(w).Encode(val) | ||
if err != nil { | ||
panic(err) | ||
} | ||
}) | ||
} | ||
|
||
func UnmarshalPluginConfigMap(v interface{}) (map[string]map[string]interface{}, error) { | ||
m, ok := v.(map[string]interface{}) | ||
if !ok { | ||
return nil, fmt.Errorf("%T is not a plugin config map", v) | ||
} | ||
|
||
result := make(map[string]map[string]interface{}) | ||
for k, v := range m { | ||
val, ok := v.(map[string]interface{}) | ||
if !ok { | ||
return nil, fmt.Errorf("key %s (%T) is not a map", k, v) | ||
} | ||
|
||
result[k] = val | ||
} | ||
|
||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# generated | ||
src/core/generated-*.tsx | ||
src/core/generated-graphql.ts | ||
|
||
# dependencies | ||
/node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ src/locales/**/*.json | |
/build | ||
|
||
# generated | ||
src/core/generated-graphql.tsx | ||
src/core/generated-graphql.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { CodegenConfig } from "@graphql-codegen/cli"; | ||
|
||
const config: CodegenConfig = { | ||
schema: [ | ||
"../../graphql/schema/**/*.graphql", | ||
"graphql/client-schema.graphql", | ||
], | ||
config: { | ||
// makes conflicting fields override rather than error | ||
onFieldTypeConflict: (_existing: unknown, other: unknown) => other, | ||
}, | ||
documents: "graphql/**/*.graphql", | ||
generates: { | ||
"src/core/generated-graphql.ts": { | ||
plugins: [ | ||
"time", | ||
"typescript", | ||
"typescript-operations", | ||
"typescript-react-apollo", | ||
], | ||
config: { | ||
strictScalars: true, | ||
scalars: { | ||
Time: "string", | ||
Timestamp: "string", | ||
Map: "{ [key: string]: unknown }", | ||
BoolMap: "{ [key: string]: boolean }", | ||
PluginConfigMap: "{ [id: string]: { [key: string]: unknown } }", | ||
Any: "unknown", | ||
Int64: "number", | ||
Upload: "File", | ||
UIConfig: "src/core/config#IUIConfig", | ||
SavedObjectFilter: "src/models/list-filter/types#SavedObjectFilter", | ||
SavedUIOptions: "src/models/list-filter/types#SavedUIOptions", | ||
}, | ||
withRefetchFn: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
scalar UIConfig | ||
scalar SavedObjectFilter | ||
scalar SavedUIOptions | ||
|
||
extend type ConfigResult { | ||
ui: UIConfig! | ||
} | ||
|
||
extend type SavedFilter { | ||
object_filter: SavedObjectFilter | ||
ui_options: SavedUIOptions | ||
} | ||
|
||
extend input SaveFilterInput { | ||
object_filter: SavedObjectFilter | ||
ui_options: SavedUIOptions | ||
} | ||
|
||
extend input SetDefaultFilterInput { | ||
object_filter: SavedObjectFilter | ||
ui_options: SavedUIOptions | ||
} | ||
|
||
extend type Mutation { | ||
configureUI(input: UIConfig!): UIConfig! | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.