Skip to content

Commit 6601eab

Browse files
committed
Replace .graphql queries with .ts
Because changes in a .graphql files doesn't recompile app. facebook/create-react-app#5580
1 parent f21b353 commit 6601eab

14 files changed

+67
-49
lines changed

codegen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
overwrite: true
22
schema: "http://localhost:4000"
3-
documents: "src/**/*.graphql"
3+
documents: "src/graphql/*.ts"
44
generates:
55
src/generated/graphql.tsx:
66
plugins:

graphql.schema.json

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,11 +1384,7 @@
13841384
"name": "cacheControl",
13851385
"description": null,
13861386
"isRepeatable": false,
1387-
"locations": [
1388-
"FIELD_DEFINITION",
1389-
"OBJECT",
1390-
"INTERFACE"
1391-
],
1387+
"locations": ["FIELD_DEFINITION", "OBJECT", "INTERFACE"],
13921388
"args": [
13931389
{
13941390
"name": "maxAge",
@@ -1420,11 +1416,7 @@
14201416
"name": "include",
14211417
"description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
14221418
"isRepeatable": false,
1423-
"locations": [
1424-
"FIELD",
1425-
"FRAGMENT_SPREAD",
1426-
"INLINE_FRAGMENT"
1427-
],
1419+
"locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
14281420
"args": [
14291421
{
14301422
"name": "if",
@@ -1448,11 +1440,7 @@
14481440
"name": "skip",
14491441
"description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
14501442
"isRepeatable": false,
1451-
"locations": [
1452-
"FIELD",
1453-
"FRAGMENT_SPREAD",
1454-
"INLINE_FRAGMENT"
1455-
],
1443+
"locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
14561444
"args": [
14571445
{
14581446
"name": "if",
@@ -1501,9 +1489,7 @@
15011489
"name": "specifiedBy",
15021490
"description": "Exposes a URL that specifies the behaviour of this scalar.",
15031491
"isRepeatable": false,
1504-
"locations": [
1505-
"SCALAR"
1506-
],
1492+
"locations": ["SCALAR"],
15071493
"args": [
15081494
{
15091495
"name": "url",
@@ -1525,4 +1511,4 @@
15251511
}
15261512
]
15271513
}
1528-
}
1514+
}

src/graphql/CreateUser.graphql

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/graphql/CreateUser.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { gql } from "@apollo/client/core";
2+
import { UserInfo } from "./UserInfo";
3+
4+
export const CreateUser = gql`
5+
mutation CreateUser($createUserInput: CreateUserInput!) {
6+
createUser(createUserInput: $createUserInput) {
7+
...UserInfo
8+
}
9+
}
10+
${UserInfo}
11+
`;

src/graphql/GetUser.graphql

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/graphql/GetUser.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { gql } from "@apollo/client/core";
2+
import { UserInfo } from "./UserInfo";
3+
4+
export const GetUser = gql`
5+
query GetUser($id: ID!) {
6+
user(id: $id) {
7+
...UserInfo
8+
}
9+
}
10+
${UserInfo}
11+
`;

src/graphql/RemoveUser.graphql

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/graphql/RemoveUser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { gql } from "@apollo/client/core";
2+
3+
export const RemoveUser = gql`
4+
mutation RemoveUser($id: ID!) {
5+
removeUser(id: $id)
6+
}
7+
`;

src/graphql/UpdateUser.graphql

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/graphql/UpdateUser.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { gql } from "@apollo/client/core";
2+
import { UserInfo } from "./UserInfo";
3+
4+
export const UpdateUser = gql`
5+
mutation UpdateUser($id: ID!, $updateUserInput: UpdateUserInput!) {
6+
updateUser(id: $id, updateUserInput: $updateUserInput) {
7+
...UserInfo
8+
}
9+
}
10+
${UserInfo}
11+
`;

src/graphql/UserInfo.graphql

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/graphql/UserInfo.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { gql } from "@apollo/client/core";
2+
3+
export const UserInfo = gql`
4+
fragment UserInfo on User {
5+
id
6+
name
7+
username
8+
email
9+
}
10+
`;

src/graphql/UsersList.graphql

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/graphql/UsersList.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { gql } from "@apollo/client/core";
2+
import { UserInfo } from "./UserInfo";
3+
4+
export const UsersList = gql`
5+
query UsersList {
6+
users {
7+
...UserInfo
8+
}
9+
}
10+
${UserInfo}
11+
`;

0 commit comments

Comments
 (0)