aldikhan13

Next Update Feature

Feb 16th, 2022 (edited)
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Target Feature for next update version SiJago is GraphQL Client,
  3. * if you're interested, you can fork and pull request this repository.
  4. *
  5. * author: Restu Wahyu Saputra
  6. * repository: https://github.com/restuwahyu13/sijago
  7. * npm: https://www.npmjs.com/package/sijago
  8. **/
  9.  
  10.  
  11. ;(async () => {
  12.  
  13.     // ## Target Feature for Graphql Variables
  14.  
  15.     const { res } = await sijago.query({
  16.         url: 'https://graphqlzero.almansi.me/api',
  17.         variables: {
  18.             name: 'getAlbumById',
  19.             type: { $id: 'ID!' },
  20.             query: { $id: 1 }
  21.         },
  22.         body: {
  23.             albums: {
  24.                 id: scalar.GraphqlString,
  25.                 title: scalar.GraphqlString,
  26.                 user: {
  27.                     name: scalar.GraphqlString,
  28.                     email: scalar.GraphqlString
  29.                 },
  30.                 photos: {
  31.                     data: {
  32.                         title: scalar.GraphqlString,
  33.                         url: scalar.GraphqlString
  34.                     }
  35.                 }
  36.             }
  37.         }
  38.     })
  39.  
  40.     // ## Target Feature for Graphql Operation
  41.  
  42.     const { res } = await sijago.query({
  43.         url: 'https://graphqlzero.almansi.me/api',
  44.         operation: 'getAlbumById',
  45.         body: {
  46.             albums: {
  47.                 data: {
  48.                     id: scalar.GraphqlString,
  49.                     title: scalar.GraphqlString,
  50.                     user: {
  51.                         name: scalar.GraphqlString,
  52.                         email: scalar.GraphqlString
  53.                     },
  54.                     photos: {
  55.                         data: {
  56.                             title: scalar.GraphqlString,
  57.                             url: scalar.GraphqlString
  58.                         }
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.     })
  64.  
  65.     // ## Target Feature for Graphql Aliases
  66.  
  67.     const { res } = await sijago.query({
  68.         url: 'https://graphqlzero.almansi.me/api',
  69.         aliases: 'getAlbumById',
  70.         body: {
  71.             albums: {
  72.                 data: {
  73.                     id: scalar.GraphqlString,
  74.                     title: scalar.GraphqlString,
  75.                     user: {
  76.                         name: scalar.GraphqlString,
  77.                         email: scalar.GraphqlString
  78.                     },
  79.                     photos: {
  80.                         data: {
  81.                             title: scalar.GraphqlString,
  82.                             url: scalar.GraphqlString
  83.                         }
  84.                     }
  85.                 }
  86.             }
  87.         }
  88.     })
  89.  
  90.     // ## Target Feature for Graphql Directives
  91.  
  92.     const { res } = await sijago.query({
  93.         url: 'https://graphqlzero.almansi.me/api',
  94.         directives: {
  95.             data: {
  96.                 id: { type: 'skip', value: true },
  97.                 title: { type: 'skip', value: true },
  98.                 user: { name: { type: 'include', value: false } }
  99.             }
  100.         },
  101.         body: {
  102.             albums: {
  103.                 data: {
  104.                     id: scalar.GraphqlString,
  105.                     title: scalar.GraphqlString,
  106.                     user: {
  107.                         name: scalar.GraphqlString,
  108.                         email: scalar.GraphqlString
  109.                     },
  110.                     photos: {
  111.                         data: {
  112.                             title: scalar.GraphqlString,
  113.                             url: scalar.GraphqlString
  114.                         }
  115.                     }
  116.                 }
  117.             }
  118.         }
  119.     })
  120.  
  121.     // ## Target Feature for Graphql Single Fragment
  122.  
  123.     const { res } = await sijago.query({
  124.         url: 'https://graphqlzero.almansi.me/api',
  125.         body: {
  126.             albums: {
  127.                 data: {
  128.                     id: scalar.GraphqlString,
  129.                     title: scalar.GraphqlString,
  130.                     user: {
  131.                         name: scalar.GraphqlString,
  132.                         email: scalar.GraphqlString
  133.                     }
  134.                 }
  135.             }
  136.         },
  137.         fragment: {
  138.             name: 'allPhotos',
  139.             target: 'photos',
  140.             fields: {
  141.                 data: {
  142.                     title: scalar.GraphqlString,
  143.                     url: scalar.GraphqlString
  144.                 }
  145.             }
  146.         }
  147.     })
  148.  
  149.     // ## Target Feature for Graphql Multiple Fragment
  150.  
  151.     const { res } = await sijago.query({
  152.         url: 'https://graphqlzero.almansi.me/api',
  153.         body: {
  154.             albums: {
  155.                 data: {
  156.                     id: scalar.GraphqlString,
  157.                     title: scalar.GraphqlString
  158.                 }
  159.             }
  160.         },
  161.         fragment: {
  162.             name: ['allPhotos', 'allUsers'],
  163.             target: ['photos', 'users'],
  164.             fields: [
  165.                 {
  166.                     data: {
  167.                         title: scalar.GraphqlString,
  168.                         url: scalar.GraphqlString
  169.                     }
  170.                 },
  171.                 {
  172.                     user: {
  173.                         name: scalar.GraphqlString,
  174.                         email: scalar.GraphqlString
  175.                     }
  176.                 }
  177.             ]
  178.         }
  179.     })
  180.  
  181.     // ## Target Feature for Graphql Arguments And Change body property to fields
  182.  
  183.     const { res } = await sijago.query({
  184.         url: 'https://graphqlzero.almansi.me/api',
  185.         arguments: 'albums',
  186.         fields: {
  187.             data: {
  188.                 id: sijago.scalar.GraphqlString,
  189.                 title: sijago.scalar.GraphqlString,
  190.                 user: {
  191.                     name: sijago.scalar.GraphqlString,
  192.                     email: sijago.scalar.GraphqlString
  193.                 },
  194.                 photos: {
  195.                     data: {
  196.                         title: sijago.scalar.GraphqlString,
  197.                         url: sijago.scalar.GraphqlString
  198.                     }
  199.                 }
  200.             }
  201.         }
  202.     })
  203. })()
Add Comment
Please, Sign In to add comment