Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extract typescript client from nextjs #72

Merged
merged 35 commits into from Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2a26364
feat: add new Wundergraph client package
Pagebakers Jul 11, 2022
d218815
feat: remove client from nextjs package
Pagebakers Jul 11, 2022
dc74dd4
feat: renamed WundergraphClient to WunderGraphClient
Pagebakers Jul 12, 2022
aec4047
Merge remote-tracking branch 'origin/main' into eelco/eng-141-export-…
Pagebakers Jul 12, 2022
c5c8e9e
chore: updated readme
Pagebakers Jul 12, 2022
e95e94b
chore: update package description and removed unused dependencies
Pagebakers Jul 12, 2022
5423796
Merge remote-tracking branch 'origin/main' into eelco/eng-141-export-…
Pagebakers Jul 13, 2022
cda62dc
feat: moved TypeScript client into sdk package
Pagebakers Jul 13, 2022
c13d1a0
chore: use exports to export client
Pagebakers Jul 14, 2022
0fe7f6c
chore: added readme
Pagebakers Jul 14, 2022
380ee3d
Merge branch 'main' into eelco/eng-141-export-typescript-client-from-…
Pagebakers Jul 18, 2022
c697267
docs: improved uploads example
Pagebakers Jul 18, 2022
fcbf0ba
feat: improved client types and response handling
Pagebakers Jul 18, 2022
60773bc
feat: add dist folder to exports
Pagebakers Jul 18, 2022
52feb18
chore: no need to use default
Pagebakers Jul 18, 2022
f71ace8
fix: add types to exports
Pagebakers Jul 18, 2022
20e49c4
Merge remote-tracking branch 'origin/main' into eelco/eng-141-export-…
Pagebakers Jul 18, 2022
e3c8fa1
Merge branch 'main' into eelco/eng-141-export-typescript-client-from-…
Pagebakers Jul 19, 2022
080e5e9
Merge remote-tracking branch 'origin/main' into eelco/eng-141-export-…
Pagebakers Jul 19, 2022
9700624
feat: removed requiresAuthentication from client
Pagebakers Jul 19, 2022
93e0760
docs: added subscription example
Pagebakers Jul 19, 2022
54fb3a6
docs: fix subscription examples
Pagebakers Jul 20, 2022
d22e95a
Merge branch 'main' into eelco/eng-141-export-typescript-client-from-…
Pagebakers Jul 20, 2022
e564bc3
Merge branch 'main' into eelco/eng-141-export-typescript-client-from-…
Pagebakers Jul 26, 2022
c854ae1
Merge branch 'main' into eelco/eng-141-export-typescript-client-from-…
Pagebakers Jul 27, 2022
381b7db
Merge remote-tracking branch 'origin/main' into eelco/eng-141-export-…
Pagebakers Jul 27, 2022
7c2afea
Merge branch 'eelco/eng-141-export-typescript-client-from-nextjs' of …
Pagebakers Jul 27, 2022
118aa77
chore: update lockfile
Pagebakers Jul 27, 2022
26e9a57
Merge remote-tracking branch 'origin/main' into eelco/eng-141-export-…
Pagebakers Jul 27, 2022
8dd9dc9
Merge branch 'main' into eelco/eng-141-export-typescript-client-from-…
Pagebakers Aug 1, 2022
2617fa7
feat: make sure customFetch is used as a fallback everywhere
Pagebakers Aug 1, 2022
99c7b95
fix: remove ts-ignore and fix ts errors
Pagebakers Aug 1, 2022
1409dc5
fix: throw fetchUser if there is a request error
Pagebakers Aug 2, 2022
9074a1c
feat: improved client api
Pagebakers Aug 2, 2022
48db9f5
chore: make sure auth works out of the box in nextjs-testapp
Pagebakers Aug 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 16 additions & 14 deletions packages/nextjs/src/handlebar.template.ts
Expand Up @@ -2,8 +2,8 @@
export const handlebarTemplate = `
import type { {{ modelImports }} } from "./models";
import {createContext} from "react";
import { QueryArgsWithInput, SubscriptionArgs, SubscriptionArgsWithInput, hooks, WunderGraphContextProperties, Client } from "@wundergraph/nextjs";

import { hooks, WunderGraphContextProperties } from "@wundergraph/nextjs";
import { QueryArgsWithInput, SubscriptionArgs, SubscriptionArgsWithInput } from "@wundergraph/sdk/client";
export type Role = {{{ roleDefinitions }}};

{{#if hasAuthProviders}}
Expand Down Expand Up @@ -31,13 +31,13 @@ export enum S3Provider {

const defaultWunderGraphContextProperties: WunderGraphContextProperties<Role> = {
ssrCache: {},
client: null,
client: null,
clientConfig: {
applicationHash: "{{applicationHash}}",
applicationPath: "{{applicationPath}}",
baseURL: "{{baseURL}}",
sdkVersion: "{{sdkVersion}}",
authenticationEnabled: {{hasAuthProviders}},
applicationHash: "{{applicationHash}}",
applicationPath: "{{applicationPath}}",
baseURL: "{{baseURL}}",
sdkVersion: "{{sdkVersion}}",
authenticationEnabled: {{hasAuthProviders}},
},
user: null,
setUser: value => {},
Expand Down Expand Up @@ -88,14 +88,12 @@ export const useSubscription = {
{{#each subscriptionsWithInput}}
{{name}}: (args: SubscriptionArgsWithInput<{{name}}Input>) => hooks.useSubscriptionWithInput<{{name}}Input, {{name}}ResponseData,Role>(WunderGraphContext,{
operationName: "{{name}}",
isLiveQuery: false,
requiresAuthentication: {{requiresAuthentication}},
})(args),
{{/each}}
{{#each subscriptionsWithoutInput}}
{{name}}: (args?: SubscriptionArgs) => hooks.useSubscriptionWithoutInput<{{name}}ResponseData,Role>(WunderGraphContext,{
operationName: "{{name}}",
isLiveQuery: false,
requiresAuthentication: {{requiresAuthentication}},
})(args),
{{/each}}
Expand All @@ -105,16 +103,20 @@ export const useLiveQuery = {
{{#each liveQueriesWithInput}}
{{name}}: (args: SubscriptionArgsWithInput<{{name}}Input>) => hooks.useSubscriptionWithInput<{{name}}Input, {{name}}ResponseData,Role>(WunderGraphContext,{
operationName: "{{name}}",
isLiveQuery: true,
requiresAuthentication: {{requiresAuthentication}},
})(args),
})({
...args,
isLiveQuery: true,
}),
{{/each}}
{{#each liveQueriesWithoutInput}}
{{name}}: (args?: SubscriptionArgs) => hooks.useSubscriptionWithoutInput<{{name}}ResponseData,Role>(WunderGraphContext,{
operationName: "{{name}}",
isLiveQuery: true,
requiresAuthentication: {{requiresAuthentication}},
})(args),
})({
...args,
isLiveQuery: true,
}),
{{/each}}
};
`;