Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser for Graphql or Json data #44

Open
Zegoverno opened this issue Jun 5, 2020 · 3 comments
Open

parser for Graphql or Json data #44

Zegoverno opened this issue Jun 5, 2020 · 3 comments
Labels

Comments

@Zegoverno
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@stale
Copy link

stale bot commented Jul 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jul 5, 2020
@afshinm afshinm added roadmap and removed wontfix This will not be worked on labels Jul 5, 2020
@benwoodward
Copy link

benwoodward commented Jun 11, 2021

Here's a working graphql config for anyone stuck with this. Caveat: you need to set up a graphql endpoint/query that receives first: Int!, offset: Int!, keyword: Int! for this to work, i.e. an endpoint that returns a paginated list of results that is filterable if a search term is provided. Using separate endpoints for search and pagination makes the problem 10x harder to solve.

    <Grid
      {columns}
      {className}
      sort
      search={{
        enabled: true,
        server: {
          body: (prevBody, keyword) => {
            return {
              keyword: keyword
            }
          }
        }
      }}
      pagination={{
        enabled: true,
        limit: 5,
        summary: true,
        server: {
          body: (prevBody, page, limit) => {
            return {
              ...prevBody,
              first: limit,
              offset: page * limit
            }
          }
        }
      }}
      server={{
        data: (opts) => {
          return new Promise((resolve, reject) => {
            let variables = {
              keyword: "",
              first: 10,
              offset: 0,
              ...opts.body
            }

            graphQLClient.request(paginatedFilterableSearch, variables)
              .then((res) => {
                resolve({
                  data: res.data.map(item => {
                    return [item.name, transcript.description, transcript.slug]
                  }),
                  total: res.data.total_count
                })
              })
              .catch((error) => {
                reject(error)
              })
          })
        }
      }}
    />

For reference, I'm using this with https://github.com/lynxtaa/awesome-graphql-client

@twilly86
Copy link

I'm also trying to get gridjs to work with graphql

is it possible to get the data option available inside pagination so we can use a custom HTTP client for paging, sorting, searching etc?

ex) https://gridjs.io/docs/examples/custom-http-client

I'm looking for ways to get this to work with apollo client and graphql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants