No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Graphql Extension

    [v1] App Extensions
    2
    2
    318
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rainer9202 last edited by

      Good morning, I am working on a quasar project with a graphql api, I installed the app-extension-apollo extension, but I am interested in being able to execute the queries and mutations in .js files and not in .vue files, how can I import the apollo in my .js file so I can do something like apollo.query ()

      R 1 Reply Last reply Reply Quote 0
      • R
        rhscjohn @rainer9202 last edited by

        @rainer9202 You will need to import the Apollo Client into your js file.

        I created my own Apollo Client boot file and I am using Vuex. Vuex is just a JavaScript file. Not an exact match to what you are doing but should be close enough to get you started. Hope this helps.

        Here is how I import the Apollo Client into a Vuex js file.

        import gql from 'graphql-tag'
        import { apolloProvider } from 'boot/apolloClient'
        import { Notify } from 'quasar'
        
        const gqlClient = apolloProvider.defaultClient
        

        This is an example of a query with parameters.

        const response = await gqlClient.query({
                query: gql`
                  query AllScheduledRecordings(
                    $orderBy: [OrderByFields]
                    $filterBy: [FilterByFields]
                    $between: [BetweenFields]
                    $whereIn: [WhereInField]
                    $page: Page
                  ) {
                    allScheduledRecordings(
                      orderBy: $orderBy
                      filterBy: $filterBy
                      between: $between
                      whereIn: $whereIn
                      page: $page
                    ) {
                      oid
                      name
                      channelOid
                      recurrenceOid
                      channelName
                      filename
                      status
                      startTimeLocal
                      endTimeLocal
                      failureReason
                      eventDetails
                      landscapeUrl
                      posterUrl
                      logoUrl
                      videoFiles {
                        name
                        base
                        dir
                        ext
                        baseURL
                      }
                    }
                  }
                `,
                variables: {
                  ...payload
                }
              })
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post