Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Target Feature for next update version SiJago is GraphQL Client,
- * if you're interested, you can fork and pull request this repository.
- *
- * author: Restu Wahyu Saputra
- * repository: https://github.com/restuwahyu13/sijago
- * npm: https://www.npmjs.com/package/sijago
- **/
- ;(async () => {
- // ## Target Feature for Graphql Variables
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- variables: {
- name: 'getAlbumById',
- type: { $id: 'ID!' },
- query: { $id: 1 }
- },
- body: {
- albums: {
- id: scalar.GraphqlString,
- title: scalar.GraphqlString,
- user: {
- name: scalar.GraphqlString,
- email: scalar.GraphqlString
- },
- photos: {
- data: {
- title: scalar.GraphqlString,
- url: scalar.GraphqlString
- }
- }
- }
- }
- })
- // ## Target Feature for Graphql Operation
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- operation: 'getAlbumById',
- body: {
- albums: {
- data: {
- id: scalar.GraphqlString,
- title: scalar.GraphqlString,
- user: {
- name: scalar.GraphqlString,
- email: scalar.GraphqlString
- },
- photos: {
- data: {
- title: scalar.GraphqlString,
- url: scalar.GraphqlString
- }
- }
- }
- }
- }
- })
- // ## Target Feature for Graphql Aliases
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- aliases: 'getAlbumById',
- body: {
- albums: {
- data: {
- id: scalar.GraphqlString,
- title: scalar.GraphqlString,
- user: {
- name: scalar.GraphqlString,
- email: scalar.GraphqlString
- },
- photos: {
- data: {
- title: scalar.GraphqlString,
- url: scalar.GraphqlString
- }
- }
- }
- }
- }
- })
- // ## Target Feature for Graphql Directives
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- directives: {
- data: {
- id: { type: 'skip', value: true },
- title: { type: 'skip', value: true },
- user: { name: { type: 'include', value: false } }
- }
- },
- body: {
- albums: {
- data: {
- id: scalar.GraphqlString,
- title: scalar.GraphqlString,
- user: {
- name: scalar.GraphqlString,
- email: scalar.GraphqlString
- },
- photos: {
- data: {
- title: scalar.GraphqlString,
- url: scalar.GraphqlString
- }
- }
- }
- }
- }
- })
- // ## Target Feature for Graphql Single Fragment
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- body: {
- albums: {
- data: {
- id: scalar.GraphqlString,
- title: scalar.GraphqlString,
- user: {
- name: scalar.GraphqlString,
- email: scalar.GraphqlString
- }
- }
- }
- },
- fragment: {
- name: 'allPhotos',
- target: 'photos',
- fields: {
- data: {
- title: scalar.GraphqlString,
- url: scalar.GraphqlString
- }
- }
- }
- })
- // ## Target Feature for Graphql Multiple Fragment
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- body: {
- albums: {
- data: {
- id: scalar.GraphqlString,
- title: scalar.GraphqlString
- }
- }
- },
- fragment: {
- name: ['allPhotos', 'allUsers'],
- target: ['photos', 'users'],
- fields: [
- {
- data: {
- title: scalar.GraphqlString,
- url: scalar.GraphqlString
- }
- },
- {
- user: {
- name: scalar.GraphqlString,
- email: scalar.GraphqlString
- }
- }
- ]
- }
- })
- // ## Target Feature for Graphql Arguments And Change body property to fields
- const { res } = await sijago.query({
- url: 'https://graphqlzero.almansi.me/api',
- arguments: 'albums',
- fields: {
- data: {
- id: sijago.scalar.GraphqlString,
- title: sijago.scalar.GraphqlString,
- user: {
- name: sijago.scalar.GraphqlString,
- email: sijago.scalar.GraphqlString
- },
- photos: {
- data: {
- title: sijago.scalar.GraphqlString,
- url: sijago.scalar.GraphqlString
- }
- }
- }
- }
- })
- })()
Add Comment
Please, Sign In to add comment