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]100 Hasuraからデータを取って来て,変更前と変更後の値をconsoleに書き出す処理 #101

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions frontend/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import type { CodegenConfig } from "@graphql-codegen/cli";
const hasuraSchema = {
[process.env.HASURA_GRAPHQL_URL!]: {
headers: {
"x-hasura-admin-secret": process.env.HASURA_GRAPHQL_ADMIN_SECRET || "",
"x-hasura-admin-secret":
process.env.NEXT_PUBLIC_HASURA_GRAPHQL_ADMIN_SECRET || "",
},
},
};

const config: CodegenConfig = {
overwrite: true,
config: {
skipTypename: false,
withHooks: true,
Expand All @@ -17,9 +19,12 @@ const config: CodegenConfig = {
gqlImport: "@urql/core#gql",
},
schema: [hasuraSchema],
hooks: {
afterAllFileWrite: ["prettier --write"],
},
generates: {
"./src/graphql/types.ts": {
documents: "query.graphql",
documents: "src/gql/*.gql",
plugins: [
"typescript",
"typescript-operations",
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/gql/user_entities.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query GetOneUserName($id: String!) {
userEntityByPk(id: $id) {
firstName
lastName
}
}
126 changes: 124 additions & 2 deletions frontend/src/graphql/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { gql } from "@urql/core";
import { IntrospectionQuery } from "graphql";
import * as Urql from "urql";

export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
Expand All @@ -20,6 +22,7 @@ export type Incremental<T> =
| {
[P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never;
};
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: { input: string; output: string };
Expand All @@ -28,6 +31,7 @@ export type Scalars = {
Int: { input: number; output: number };
Float: { input: number; output: number };
bigint: { input: any; output: any };
bytea: { input: any; output: any };
};

/** Boolean expression to compare columns of type "bigint". All fields are combined with logical 'AND'. */
Expand Down Expand Up @@ -349,6 +353,19 @@ export type BureauVarianceOrderBy = {
id?: InputMaybe<OrderBy>;
};

/** Boolean expression to compare columns of type "bytea". All fields are combined with logical 'AND'. */
export type ByteaComparisonExp = {
_eq?: InputMaybe<Scalars["bytea"]["input"]>;
_gt?: InputMaybe<Scalars["bytea"]["input"]>;
_gte?: InputMaybe<Scalars["bytea"]["input"]>;
_in?: InputMaybe<Array<Scalars["bytea"]["input"]>>;
_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["bytea"]["input"]>;
_lte?: InputMaybe<Scalars["bytea"]["input"]>;
_neq?: InputMaybe<Scalars["bytea"]["input"]>;
_nin?: InputMaybe<Array<Scalars["bytea"]["input"]>>;
};

/** ordering argument of a cursor */
export enum CursorOrdering {
/** ascending ordering of the cursor */
Expand Down Expand Up @@ -1510,7 +1527,7 @@ export type KeycloakGroupBoolExp = {
export enum KeycloakGroupConstraint {
/** unique or primary key constraint on columns "id" */
ConstraintGroup = "constraint_group",
/** unique or primary key constraint on columns "parent_group", "realm_id", "name" */
/** unique or primary key constraint on columns "realm_id", "name", "parent_group" */
SiblingNames = "sibling_names",
}

Expand Down Expand Up @@ -2130,6 +2147,9 @@ export type StringComparisonExp = {
export type UserAttribute = {
__typename?: "UserAttribute";
id: Scalars["String"]["output"];
longValue?: Maybe<Scalars["String"]["output"]>;
longValueHash?: Maybe<Scalars["bytea"]["output"]>;
longValueHashLowerCase?: Maybe<Scalars["bytea"]["output"]>;
name: Scalars["String"]["output"];
userId: Scalars["String"]["output"];
/** An object relationship */
Expand Down Expand Up @@ -2182,6 +2202,9 @@ export type UserAttributeBoolExp = {
_not?: InputMaybe<UserAttributeBoolExp>;
_or?: InputMaybe<Array<UserAttributeBoolExp>>;
id?: InputMaybe<StringComparisonExp>;
longValue?: InputMaybe<StringComparisonExp>;
longValueHash?: InputMaybe<ByteaComparisonExp>;
longValueHashLowerCase?: InputMaybe<ByteaComparisonExp>;
name?: InputMaybe<StringComparisonExp>;
userId?: InputMaybe<StringComparisonExp>;
user_entity?: InputMaybe<UserEntityBoolExp>;
Expand All @@ -2197,6 +2220,9 @@ export enum UserAttributeConstraint {
/** input type for inserting data into table "user_attribute" */
export type UserAttributeInsertInput = {
id?: InputMaybe<Scalars["String"]["input"]>;
longValue?: InputMaybe<Scalars["String"]["input"]>;
longValueHash?: InputMaybe<Scalars["bytea"]["input"]>;
longValueHashLowerCase?: InputMaybe<Scalars["bytea"]["input"]>;
name?: InputMaybe<Scalars["String"]["input"]>;
userId?: InputMaybe<Scalars["String"]["input"]>;
user_entity?: InputMaybe<UserEntityObjRelInsertInput>;
Expand All @@ -2207,6 +2233,7 @@ export type UserAttributeInsertInput = {
export type UserAttributeMaxFields = {
__typename?: "UserAttributeMaxFields";
id?: Maybe<Scalars["String"]["output"]>;
longValue?: Maybe<Scalars["String"]["output"]>;
name?: Maybe<Scalars["String"]["output"]>;
userId?: Maybe<Scalars["String"]["output"]>;
value?: Maybe<Scalars["String"]["output"]>;
Expand All @@ -2215,6 +2242,7 @@ export type UserAttributeMaxFields = {
/** order by max() on columns of table "user_attribute" */
export type UserAttributeMaxOrderBy = {
id?: InputMaybe<OrderBy>;
longValue?: InputMaybe<OrderBy>;
name?: InputMaybe<OrderBy>;
userId?: InputMaybe<OrderBy>;
value?: InputMaybe<OrderBy>;
Expand All @@ -2224,6 +2252,7 @@ export type UserAttributeMaxOrderBy = {
export type UserAttributeMinFields = {
__typename?: "UserAttributeMinFields";
id?: Maybe<Scalars["String"]["output"]>;
longValue?: Maybe<Scalars["String"]["output"]>;
name?: Maybe<Scalars["String"]["output"]>;
userId?: Maybe<Scalars["String"]["output"]>;
value?: Maybe<Scalars["String"]["output"]>;
Expand All @@ -2232,6 +2261,7 @@ export type UserAttributeMinFields = {
/** order by min() on columns of table "user_attribute" */
export type UserAttributeMinOrderBy = {
id?: InputMaybe<OrderBy>;
longValue?: InputMaybe<OrderBy>;
name?: InputMaybe<OrderBy>;
userId?: InputMaybe<OrderBy>;
value?: InputMaybe<OrderBy>;
Expand All @@ -2256,6 +2286,9 @@ export type UserAttributeOnConflict = {
/** Ordering options when selecting data from "user_attribute". */
export type UserAttributeOrderBy = {
id?: InputMaybe<OrderBy>;
longValue?: InputMaybe<OrderBy>;
longValueHash?: InputMaybe<OrderBy>;
longValueHashLowerCase?: InputMaybe<OrderBy>;
name?: InputMaybe<OrderBy>;
userId?: InputMaybe<OrderBy>;
user_entity?: InputMaybe<UserEntityOrderBy>;
Expand All @@ -2272,6 +2305,12 @@ export enum UserAttributeSelectColumn {
/** column name */
Id = "id",
/** column name */
LongValue = "longValue",
/** column name */
LongValueHash = "longValueHash",
/** column name */
LongValueHashLowerCase = "longValueHashLowerCase",
/** column name */
Name = "name",
/** column name */
UserId = "userId",
Expand All @@ -2282,6 +2321,9 @@ export enum UserAttributeSelectColumn {
/** input type for updating data in table "user_attribute" */
export type UserAttributeSetInput = {
id?: InputMaybe<Scalars["String"]["input"]>;
longValue?: InputMaybe<Scalars["String"]["input"]>;
longValueHash?: InputMaybe<Scalars["bytea"]["input"]>;
longValueHashLowerCase?: InputMaybe<Scalars["bytea"]["input"]>;
name?: InputMaybe<Scalars["String"]["input"]>;
userId?: InputMaybe<Scalars["String"]["input"]>;
value?: InputMaybe<Scalars["String"]["input"]>;
Expand All @@ -2298,6 +2340,9 @@ export type UserAttributeStreamCursorInput = {
/** Initial value of the column from where the streaming should start */
export type UserAttributeStreamCursorValueInput = {
id?: InputMaybe<Scalars["String"]["input"]>;
longValue?: InputMaybe<Scalars["String"]["input"]>;
longValueHash?: InputMaybe<Scalars["bytea"]["input"]>;
longValueHashLowerCase?: InputMaybe<Scalars["bytea"]["input"]>;
name?: InputMaybe<Scalars["String"]["input"]>;
userId?: InputMaybe<Scalars["String"]["input"]>;
value?: InputMaybe<Scalars["String"]["input"]>;
Expand All @@ -2308,6 +2353,12 @@ export enum UserAttributeUpdateColumn {
/** column name */
Id = "id",
/** column name */
LongValue = "longValue",
/** column name */
LongValueHash = "longValueHash",
/** column name */
LongValueHashLowerCase = "longValueHashLowerCase",
/** column name */
Name = "name",
/** column name */
UserId = "userId",
Expand Down Expand Up @@ -2978,7 +3029,7 @@ export type UserRoleMappingBoolExp = {

/** unique or primary key constraints on table "user_role_mapping" */
export enum UserRoleMappingConstraint {
/** unique or primary key constraint on columns "role_id", "user_id" */
/** unique or primary key constraint on columns "user_id", "role_id" */
ConstraintC = "constraint_c",
}

Expand Down Expand Up @@ -4543,6 +4594,19 @@ export type UserRoleMappingAggregateBoolExpCount = {
filter?: InputMaybe<UserRoleMappingBoolExp>;
predicate: IntComparisonExp;
};

export type GetOneUserNameQueryVariables = Exact<{
id: Scalars["String"]["input"];
}>;

export type GetOneUserNameQuery = {
__typename?: "query_root";
userEntityByPk?: {
__typename?: "UserEntity";
firstName?: string | null;
lastName?: string | null;
} | null;
};
export default {
__schema: {
queryType: {
Expand Down Expand Up @@ -8048,6 +8112,30 @@ export default {
},
args: [],
},
{
name: "longValue",
type: {
kind: "SCALAR",
name: "Any",
},
args: [],
},
{
name: "longValueHash",
type: {
kind: "SCALAR",
name: "Any",
},
args: [],
},
{
name: "longValueHashLowerCase",
type: {
kind: "SCALAR",
name: "Any",
},
args: [],
},
{
name: "name",
type: {
Expand Down Expand Up @@ -8196,6 +8284,14 @@ export default {
},
args: [],
},
{
name: "longValue",
type: {
kind: "SCALAR",
name: "Any",
},
args: [],
},
{
name: "name",
type: {
Expand Down Expand Up @@ -8235,6 +8331,14 @@ export default {
},
args: [],
},
{
name: "longValue",
type: {
kind: "SCALAR",
name: "Any",
},
args: [],
},
{
name: "name",
type: {
Expand Down Expand Up @@ -16275,3 +16379,21 @@ export default {
directives: [],
},
} as unknown as IntrospectionQuery;

export const GetOneUserNameDocument = gql`
query GetOneUserName($id: String!) {
userEntityByPk(id: $id) {
firstName
lastName
}
}
`;

export function useGetOneUserNameQuery(
options: Omit<Urql.UseQueryArgs<GetOneUserNameQueryVariables>, "query">
) {
return Urql.useQuery<GetOneUserNameQuery, GetOneUserNameQueryVariables>({
query: GetOneUserNameDocument,
...options,
});
}
33 changes: 26 additions & 7 deletions frontend/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@ import "@/styles/globals.css";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import { Session } from "next-auth";
import { SessionProvider } from "next-auth/react";
import { cacheExchange, createClient, fetchExchange, Provider } from "urql";

import { Layout } from "@/components/layout";

import type { AppProps } from "next/app";

const isServer = typeof window === "undefined";

const client = createClient({
url: isServer
? process.env.HASURA_GRAPHQL_URL || ""
: process.env.NEXT_PUBLIC_HASURA_GRAPHQL_URL || "",
fetchOptions: {
headers: {
"x-hasura-admin-secret":
process.env.NEXT_PUBLIC_HASURA_GRAPHQL_ADMIN_SECRET || "",
},
},
exchanges: [cacheExchange, fetchExchange],
});

export default function App({
Component,
pageProps: { session, ...pageProps },
Expand All @@ -16,20 +32,23 @@ export default function App({
breakpoints: {
values: {
xs: 0,
sm: 660, // default: 600
sm: 660,
md: 900,
lg: 1024, // default: 1200
lg: 1024,
xl: 1536,
},
},
});

return (
<SessionProvider session={session as Session | null | undefined}>
<ThemeProvider theme={theme}>
<Layout>
<Component {...pageProps} />
</Layout>
</ThemeProvider>
<Provider value={client}>
<ThemeProvider theme={theme}>
<Layout>
<Component {...pageProps} />
</Layout>
</ThemeProvider>
</Provider>
</SessionProvider>
);
}
Loading
Loading