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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: pnpm lint
- name: Check types
run: pnpm check-types
- name: Check for changes in generated GraphQL files
- name: Check for changes in generated files
run: |
pnpm generate
git diff --name-status --exit-code .
Expand Down
22 changes: 0 additions & 22 deletions .graphqlrc.yml

This file was deleted.

9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,14 @@ You can also install application using GQL or command line. Follow the guide [ho

### Generated schema and typings

Command `generate` would generate schema and typed functions using Saleor's GraphQL endpoint. Commit the `generated` folder to your repo as they are necessary for queries and keeping track of the schema changes.
This project uses a `generate` npm script command to:

[Learn more](https://www.graphql-code-generator.com/) about GraphQL code generation.
- Generate GraphQL schema and typed functions from Saleor's GraphQL endpoint.
- Generate types for Saleor sync webhook responses from JSON schema

Commit the `generated` folder to your repo as they are necessary for queries and keeping track of the GraphQL / JSON schema changes.

To generate GraphQL types we are using [GraphQL Codegen](https://www.graphql-code-generator.com/). For generating types from JSON schema we use [json-schema-to-typescript](https://www.npmjs.com/package/json-schema-to-typescript).

### Storing registration data - APL

Expand Down
54 changes: 54 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
schema: "./graphql/schema.graphql",
documents: ["./graphql/**/*.graphql"],
generates: {
"./generated/graphql.ts": {
plugins: [
{
add: {
content:
"type JSONValue = string | number | boolean | null | { [key: string]: JSONValue } | JSONValue[];",
},
},
"typescript",
"typescript-operations",
"urql-introspection",
{
"typescript-urql": {
documentVariablePrefix: "Untyped",
fragmentVariablePrefix: "Untyped",
},
},
"typed-document-node",
],
config: {
dedupeFragments: true,
defaultScalarType: "unknown",
immutableTypes: true,
strictScalars: true,
skipTypename: true,
scalars: {
_Any: "unknown",
Date: "string",
DateTime: "string",
Decimal: "number",
Minute: "number",
GenericScalar: "JSONValue",
JSON: "JSONValue",
JSONString: "string",
Metadata: "Record<string, string>",
PositiveDecimal: "number",
Upload: "unknown",
UUID: "string",
WeightScalar: "number",
Day: "string",
Hour: "number",
},
},
},
},
};

export default config;
18 changes: 18 additions & 0 deletions generated/app-webhooks-types/order-filter-shipping-methods.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading