-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
urql
demo & bumps version
- Loading branch information
1 parent
cad313e
commit c79528b
Showing
25 changed files
with
8,250 additions
and
225 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
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,11 @@ | ||
// https://github.com/apollographql/apollo/blob/main/docs/source/devtools/apollo-config.md | ||
module.exports = { | ||
client: { | ||
service: { | ||
name: 'shop', | ||
// localSchemaFile: './schema-shop.json', | ||
url: 'http://localhost:3001/shop-api', | ||
}, | ||
includes: ['./src/data/**/*.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,41 @@ | ||
/** | ||
* https://the-guild.dev/graphql/codegen/docs/config-reference/config-field | ||
* @type {import('@graphql-codegen/cli').CodegenConfig} | ||
*/ | ||
module.exports = { | ||
overwrite: true, | ||
config: { | ||
strict: true, | ||
namingConvention: { | ||
enumValues: 'keep', | ||
}, | ||
skipTypeNameForRoot: true, | ||
dedupeFragments: true, | ||
inlineFragmentTypes: 'combine', | ||
scalars: { | ||
ID: 'string | number', | ||
Money: 'number', | ||
}, | ||
maybeValue: 'T', | ||
deprecatedFieldsWithReason: true, | ||
inputValueDeprecation: true, | ||
}, | ||
generates: { | ||
'src/generated-types.ts': { | ||
schema: 'http://localhost:3001/shop-api', | ||
documents: 'src/data/**/*.{ts,tsx}', | ||
plugins: [ | ||
{ | ||
add: { | ||
content: '/* eslint-disable */', | ||
}, | ||
}, | ||
'typescript', | ||
'typescript-operations', | ||
], | ||
}, | ||
}, | ||
hooks: { | ||
afterAllFileWrite: ['prettier --write'], | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { gql } from 'urql'; | ||
|
||
export const FRAGMENT_ADDRESS = gql` | ||
fragment Address on Address { | ||
id | ||
createdAt | ||
updatedAt | ||
fullName | ||
company | ||
streetLine1 | ||
streetLine2 | ||
province | ||
country { | ||
id | ||
code | ||
name | ||
} | ||
city | ||
phoneNumber | ||
customFields | ||
postalCode | ||
defaultBillingAddress | ||
defaultShippingAddress | ||
} | ||
`; |
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,12 @@ | ||
import { gql } from 'urql'; | ||
|
||
export const FRAGMENT_ASSET = gql` | ||
fragment Asset on Asset { | ||
id | ||
name | ||
source | ||
preview | ||
width | ||
height | ||
} | ||
`; |
20 changes: 20 additions & 0 deletions
20
packages/next-demo/src/data/fragments/fragment-customer.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,20 @@ | ||
import { gql } from 'urql'; | ||
import { FRAGMENT_ADDRESS } from './fragment-address'; | ||
|
||
export const FRAGMENT_CUSTOMER = gql` | ||
fragment Customer on Customer { | ||
id | ||
title | ||
firstName | ||
lastName | ||
emailAddress | ||
phoneNumber | ||
customFields { | ||
birthday | ||
} | ||
addresses { | ||
...Address | ||
} | ||
} | ||
${FRAGMENT_ADDRESS} | ||
`; |
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,3 @@ | ||
export * from './fragment-address'; | ||
export * from './fragment-asset'; | ||
export * from './fragment-customer'; |
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,2 @@ | ||
export * from './mutation-account'; | ||
export * from './mutation-address'; |
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,68 @@ | ||
import { gql } from 'urql'; | ||
import { FRAGMENT_CUSTOMER } from '../fragments'; | ||
/** | ||
* Verify a Customer email address with the token sent to that address. | ||
* Only applicable if authOptions.requireVerification is set to true. | ||
* If the Customer was not registered with a password in the registerCustomerAccount mutation, the a password must be provided here. | ||
*/ | ||
export const mutationVerifyCustomerAccount = gql` | ||
mutation nextVerifyCustomerAccount($token: String!, $password: String) { | ||
verifyCustomerAccount(password: $password, token: $token) { | ||
__typename | ||
... on CurrentUser { | ||
id | ||
} | ||
... on ErrorResult { | ||
errorCode | ||
message | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export const mutationUpdateCustomer = gql` | ||
mutation nextUpdateCustomer($input: UpdateCustomerInput!) { | ||
updateCustomer(input: $input) { | ||
...Customer | ||
} | ||
} | ||
${FRAGMENT_CUSTOMER} | ||
`; | ||
|
||
export const mutationUpdateCustomerPassword = gql` | ||
mutation nextUpdateCustomerPassword( | ||
$currentPassword: String! | ||
$newPassword: String! | ||
) { | ||
updateCustomerPassword( | ||
currentPassword: $currentPassword | ||
newPassword: $newPassword | ||
) { | ||
__typename | ||
... on Success { | ||
success | ||
} | ||
... on ErrorResult { | ||
errorCode | ||
message | ||
} | ||
} | ||
} | ||
`; | ||
|
||
// https://www.vendure.io/docs/graphql-api/shop/object-types/#registercustomeraccountresult | ||
export const mutationRegisterCustomerAccount = gql` | ||
# Register a Customer account with the given credentials. There are three possible registration flows | ||
mutation nextRegisterCustomerAccount($input: RegisterCustomerInput!) { | ||
registerCustomerAccount(input: $input) { | ||
__typename | ||
... on Success { | ||
success | ||
} | ||
... on ErrorResult { | ||
errorCode | ||
message | ||
} | ||
} | ||
} | ||
`; |
Oops, something went wrong.