diff --git a/codegen.yml b/codegen.yml index c48bda4..4bbfbdf 100644 --- a/codegen.yml +++ b/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: diff --git a/graphql.schema.json b/graphql.schema.json index d1f8740..3443ae4 100644 --- a/graphql.schema.json +++ b/graphql.schema.json @@ -1384,11 +1384,7 @@ "name": "cacheControl", "description": null, "isRepeatable": false, - "locations": [ - "FIELD_DEFINITION", - "OBJECT", - "INTERFACE" - ], + "locations": ["FIELD_DEFINITION", "OBJECT", "INTERFACE"], "args": [ { "name": "maxAge", @@ -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", @@ -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", @@ -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", @@ -1525,4 +1511,4 @@ } ] } -} \ No newline at end of file +} diff --git a/src/graphql/CreateUser.graphql b/src/graphql/CreateUser.graphql deleted file mode 100644 index f619ba1..0000000 --- a/src/graphql/CreateUser.graphql +++ /dev/null @@ -1,5 +0,0 @@ -mutation CreateUser($createUserInput: CreateUserInput!) { - createUser(createUserInput: $createUserInput) { - ...UserInfo - } -} diff --git a/src/graphql/CreateUser.ts b/src/graphql/CreateUser.ts new file mode 100644 index 0000000..821ab2f --- /dev/null +++ b/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} +`; diff --git a/src/graphql/GetUser.graphql b/src/graphql/GetUser.graphql deleted file mode 100644 index 33c8a7e..0000000 --- a/src/graphql/GetUser.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query GetUser($id: ID!) { - user(id: $id) { - ...UserInfo - } -} diff --git a/src/graphql/GetUser.ts b/src/graphql/GetUser.ts new file mode 100644 index 0000000..d595868 --- /dev/null +++ b/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} +`; diff --git a/src/graphql/RemoveUser.graphql b/src/graphql/RemoveUser.graphql deleted file mode 100644 index d00dffe..0000000 --- a/src/graphql/RemoveUser.graphql +++ /dev/null @@ -1,3 +0,0 @@ -mutation RemoveUser($id: ID!) { - removeUser(id: $id) -} diff --git a/src/graphql/RemoveUser.ts b/src/graphql/RemoveUser.ts new file mode 100644 index 0000000..17627b1 --- /dev/null +++ b/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) + } +`; diff --git a/src/graphql/UpdateUser.graphql b/src/graphql/UpdateUser.graphql deleted file mode 100644 index c22c2e4..0000000 --- a/src/graphql/UpdateUser.graphql +++ /dev/null @@ -1,5 +0,0 @@ -mutation UpdateUser($id: ID!, $updateUserInput: UpdateUserInput!) { - updateUser(id: $id, updateUserInput: $updateUserInput) { - ...UserInfo - } -} diff --git a/src/graphql/UpdateUser.ts b/src/graphql/UpdateUser.ts new file mode 100644 index 0000000..05acb73 --- /dev/null +++ b/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} +`; diff --git a/src/graphql/UserInfo.graphql b/src/graphql/UserInfo.graphql deleted file mode 100644 index 2526039..0000000 --- a/src/graphql/UserInfo.graphql +++ /dev/null @@ -1,6 +0,0 @@ -fragment UserInfo on User { - id - name - username - email -} diff --git a/src/graphql/UserInfo.ts b/src/graphql/UserInfo.ts new file mode 100644 index 0000000..cf1e110 --- /dev/null +++ b/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 + } +`; diff --git a/src/graphql/UsersList.graphql b/src/graphql/UsersList.graphql deleted file mode 100644 index 615f02a..0000000 --- a/src/graphql/UsersList.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query UsersList { - users { - ...UserInfo - } -} diff --git a/src/graphql/UsersList.ts b/src/graphql/UsersList.ts new file mode 100644 index 0000000..fab68df --- /dev/null +++ b/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} +`;