Skip to content

Commit

Permalink
feat(graphql): dont import from generated/graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
topheman committed May 24, 2021
1 parent 3c4b33c commit 0c5a1a7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Expand Up @@ -65,5 +65,11 @@ module.exports = {
peerDependencies: false,
},
],
"no-restricted-imports": [
"error",
{
patterns: ["*/generated/graphql"],
},
],
},
};
@@ -1,4 +1,4 @@
import { Organization } from "../../generated/graphql";
import { Organization } from "../../libs/graphql";

export type AppOrganizationProfileProps = {
organization?: Organization;
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppUserProfile/AppUserProfile.tsx
@@ -1,4 +1,4 @@
import { User } from "../../generated/graphql";
import { User } from "../../libs/graphql";

export type AppUserProfileProps = {
user?: User;
Expand Down
2 changes: 1 addition & 1 deletion src/components/TheOwnerProfile/TheOwnerProfile.tsx
Expand Up @@ -4,7 +4,7 @@ import {
useGetRepositoryOwnerWithRepositoriesQuery,
useGetProfileReadmeQuery,
Blob,
} from "../../generated/graphql";
} from "../../libs/graphql";
import { isUser, isOrganization } from "../../utils/type-guards";
import AppUserProfile from "../AppUserProfile/AppUserProfile";
import AppOrganizationProfile from "../AppOrganizationProfile/AppOrganizationProfile";
Expand Down
7 changes: 7 additions & 0 deletions src/libs/graphql.tsx
@@ -0,0 +1,7 @@
/* eslint-disable no-restricted-imports */

/**
* src/generated/graphql.tsx is generated with `npm run graphql-codegen`
* we don't import directly from the generated file in order to be able to make any overrides
*/
export * from "../generated/graphql";
2 changes: 1 addition & 1 deletion src/pages/[owner].tsx
Expand Up @@ -14,7 +14,7 @@ import {
GetRepositoryOwnerWithRepositoriesDocument,
GetProfileReadmeQuery,
GetProfileReadmeDocument,
} from "../generated/graphql";
} from "../libs/graphql";
import { isUser } from "../utils/type-guards";
import type { TheOwnerProfileProps } from "../components/TheOwnerProfile/TheOwnerProfile";

Expand Down
2 changes: 1 addition & 1 deletion src/utils/type-guards.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
import { User, Organization } from "../generated/graphql";
import { User, Organization } from "../libs/graphql";

/**
* - Using type predicates: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
Expand Down

0 comments on commit 0c5a1a7

Please sign in to comment.