-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utilized fragments to reuse request object
- Loading branch information
1 parent
cafead6
commit 17aaa34
Showing
5 changed files
with
38 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const userFragments = `fragment userFragments on user { | ||
id | ||
name | ||
gender | ||
status | ||
}`; | ||
|
||
export const userResponseFields = `id | ||
name | ||
gender | ||
status`; | ||
|
||
//TODO: enhance this | ||
export const fragmentBuilder = (fragmentName: string, fragmentObject: string, fieldType: string) => { | ||
return `fragment ${fragmentName} on ${fieldType} { | ||
${fragmentObject} | ||
}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
import { userResponseFields } from './fragments'; | ||
|
||
export const queryAllUserPayload = `{ | ||
users { | ||
totalCount | ||
nodes { | ||
gender | ||
id | ||
name | ||
status | ||
${userResponseFields} | ||
} | ||
} | ||
}`; | ||
|
||
export const queryUserByIdPayload = (id: number) => { | ||
return `query User { | ||
user(id: "${id}") { | ||
gender | ||
id | ||
name | ||
status | ||
${userResponseFields} | ||
} | ||
}`; | ||
}; |