Skip to content

Commit

Permalink
Replace .graphql queries with .ts
Browse files Browse the repository at this point in the history
Because changes in a .graphql files doesn't recompile app.
facebook/create-react-app#5580
  • Loading branch information
chenaski committed May 2, 2021
1 parent f21b353 commit 6601eab
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 49 deletions.
2 changes: 1 addition & 1 deletion codegen.yml
@@ -1,6 +1,6 @@
overwrite: true
schema: "http://localhost:4000"
documents: "src/**/*.graphql"
documents: "src/graphql/*.ts"
generates:
src/generated/graphql.tsx:
plugins:
Expand Down
24 changes: 5 additions & 19 deletions graphql.schema.json
Expand Up @@ -1384,11 +1384,7 @@
"name": "cacheControl",
"description": null,
"isRepeatable": false,
"locations": [
"FIELD_DEFINITION",
"OBJECT",
"INTERFACE"
],
"locations": ["FIELD_DEFINITION", "OBJECT", "INTERFACE"],
"args": [
{
"name": "maxAge",
Expand Down Expand Up @@ -1420,11 +1416,7 @@
"name": "include",
"description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
"isRepeatable": false,
"locations": [
"FIELD",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT"
],
"locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
"args": [
{
"name": "if",
Expand All @@ -1448,11 +1440,7 @@
"name": "skip",
"description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
"isRepeatable": false,
"locations": [
"FIELD",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT"
],
"locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
"args": [
{
"name": "if",
Expand Down Expand Up @@ -1501,9 +1489,7 @@
"name": "specifiedBy",
"description": "Exposes a URL that specifies the behaviour of this scalar.",
"isRepeatable": false,
"locations": [
"SCALAR"
],
"locations": ["SCALAR"],
"args": [
{
"name": "url",
Expand All @@ -1525,4 +1511,4 @@
}
]
}
}
}
5 changes: 0 additions & 5 deletions src/graphql/CreateUser.graphql

This file was deleted.

11 changes: 11 additions & 0 deletions src/graphql/CreateUser.ts
@@ -0,0 +1,11 @@
import { gql } from "@apollo/client/core";
import { UserInfo } from "./UserInfo";

export const CreateUser = gql`
mutation CreateUser($createUserInput: CreateUserInput!) {
createUser(createUserInput: $createUserInput) {
...UserInfo
}
}
${UserInfo}
`;
5 changes: 0 additions & 5 deletions src/graphql/GetUser.graphql

This file was deleted.

11 changes: 11 additions & 0 deletions src/graphql/GetUser.ts
@@ -0,0 +1,11 @@
import { gql } from "@apollo/client/core";
import { UserInfo } from "./UserInfo";

export const GetUser = gql`
query GetUser($id: ID!) {
user(id: $id) {
...UserInfo
}
}
${UserInfo}
`;
3 changes: 0 additions & 3 deletions src/graphql/RemoveUser.graphql

This file was deleted.

7 changes: 7 additions & 0 deletions src/graphql/RemoveUser.ts
@@ -0,0 +1,7 @@
import { gql } from "@apollo/client/core";

export const RemoveUser = gql`
mutation RemoveUser($id: ID!) {
removeUser(id: $id)
}
`;
5 changes: 0 additions & 5 deletions src/graphql/UpdateUser.graphql

This file was deleted.

11 changes: 11 additions & 0 deletions src/graphql/UpdateUser.ts
@@ -0,0 +1,11 @@
import { gql } from "@apollo/client/core";
import { UserInfo } from "./UserInfo";

export const UpdateUser = gql`
mutation UpdateUser($id: ID!, $updateUserInput: UpdateUserInput!) {
updateUser(id: $id, updateUserInput: $updateUserInput) {
...UserInfo
}
}
${UserInfo}
`;
6 changes: 0 additions & 6 deletions src/graphql/UserInfo.graphql

This file was deleted.

10 changes: 10 additions & 0 deletions src/graphql/UserInfo.ts
@@ -0,0 +1,10 @@
import { gql } from "@apollo/client/core";

export const UserInfo = gql`
fragment UserInfo on User {
id
name
username
email
}
`;
5 changes: 0 additions & 5 deletions src/graphql/UsersList.graphql

This file was deleted.

11 changes: 11 additions & 0 deletions src/graphql/UsersList.ts
@@ -0,0 +1,11 @@
import { gql } from "@apollo/client/core";
import { UserInfo } from "./UserInfo";

export const UsersList = gql`
query UsersList {
users {
...UserInfo
}
}
${UserInfo}
`;

0 comments on commit 6601eab

Please sign in to comment.