useQueryClient isn't defined - react-query

Pretty simple. We're using "react-query": "^2.26.1", and when I try this, from the v2 docs:
import { useQueryClient } from 'react-query'
it doesn't recognize it as existing.
Indeed, node_modules/react-query/types/react/index.d.ts doesn't have it:
export { ReactQueryCacheProvider, useQueryCache, } from './ReactQueryCacheProvider';
export { ReactQueryConfigProvider } from './ReactQueryConfigProvider';
export { ReactQueryErrorResetBoundary, useErrorResetBoundary, } from './ReactQueryErrorResetBoundary';
export { useIsFetching } from './useIsFetching';
export { useMutation } from './useMutation';
export { useQuery } from './useQuery';
export { usePaginatedQuery } from './usePaginatedQuery';
export { useInfiniteQuery } from './useInfiniteQuery';
export { UseQueryObjectConfig } from './useQuery';
export { UseInfiniteQueryObjectConfig } from './useInfiniteQuery';
export { UsePaginatedQueryObjectConfig } from './usePaginatedQuery';
export { ReactQueryCacheProviderProps } from './ReactQueryCacheProvider';
export { ReactQueryConfigProviderProps } from './ReactQueryConfigProvider';
export { ReactQueryErrorResetBoundaryProps } from './ReactQueryErrorResetBoundary';
What's going on here?

The v2 docs incorrectly show v3 content. useQueryClient doesn't exist in v2.
The best way to consume the v2 docs would be here:
https://github.com/TanStack/query/tree/v2.26.4/docs/src/pages
However, please keep in mind that the last v2 release was pretty much 2 years ago (2020-12-07) is not actively maintained. v4 is the latest version (available under #tanstack/react-query), and work on v5 will start soon
https://tanstack.com/query/v4

Related

GitHub Projects Beta - How to get the data from a view in the API

My company is using the new GitHub projects beta and we're really enjoying the experience, but we're facing a problem and it is how to export the data from a specific view (or even all the data) with all the custom columns that we have.
The ideal solution for us is to get this same data as JSON using the API.
Using https://api.github.com/orgs/.../issues does not work because the issues does not have the custom columns that we create inside the project, and https://api.github.com/orgs/.../projects does not have the data of the issues.
Any idea or work-around to get this data easily using APIs?
After reading the feedback post on GitHub, it's not possible to do it with API, just GraphQL, at least for now.
So my problem was solved with this useful code.
To get the first 100 project from your organization and their ID:
query{
organization(login: "MY_ORG") {
projectsNext(first: 20) {
nodes {
id
title
}
}
}
}
To get the first 100 issues and drafts from a specific project:
{
node(id: "My_Project_ID") {
... on ProjectNext {
items(first: 100, after: null) {
edges {
cursor
}
nodes {
content {
... on Issue {
title
assignees(first: 1) {
nodes {
login
}
}
milestone {
title
}
labels(first: 5) {
nodes {
name
}
}
repository{
name
}
}
}
fieldValues(first: 15) {
nodes {
value
projectField {
name
settings
}
}
}
}
}
}
}
}
Those codes can be easily tested in THIS LINK

Jenkins Multibranch-Pipeline JobDSL can't specify github url

I'm creating a Multibranch Pipeline job with JobDSL , and I want to specify my github url , but it's not working.
The job which I created it display "https://github.com/jackson/multibranch-Pipeline.git" ,
not https://mycompanygithub.com/jackson/multibranch-Pipeline.git
Any idea how theses other parameters can be added in ?
or other solution
multibranchPipelineJob('Jenkins/Multibranch-Pipeline/GitHub_Basic') {
branchSources {
branchSource {
source {
github {
repositoryUrl('https://mycompanygithub.com')
credentialsId('mycredentialsid')
repoOwner('jackson')
repository('multibranch-Pipeline.git')
configuredByUrl(true)
}
}
}
}
}
Actually your configuration is correct, your are just missing one parameter: apiUri
// The server to connect to.
apiUri(String value)
Without it, it takes the default github.com as the base domain for the repository regardless of what is configured in the repositoryUrl parameter.
Try the following:
multibranchPipelineJob('Jenkins/Multibranch-Pipeline/GitHub_Basic') {
branchSources {
branchSource {
source {
github {
apiUri('https://mycompanygithub.com/api/v3')
repositoryUrl('https://mycompanygithub.com')
credentialsId('mycredentialsid')
repoOwner('jackson')
repository('multibranch-Pipeline.git')
configuredByUrl(true)
}
}
}
}
}
By the way you can see the full documentation of the Job DSL of this plugin at the following URL on your own Jenkins server:
YOUR_JENKINS_URL/plugin/job-dsl/api-viewer/index.html#method/javaposse.jobdsl.dsl.DslFactory.multibranchPipelineJob

Drools: Executing multiple rules simultaneously via REST

I am new to drools. I want to fire multiple rules simultaneously depending on the condition.
I am using batch-execution command as follows, but it gives me error : "Bad request, no commands to be executed - either wrong format or no data"
{
"batch-execution":{
"lookup":"defaultKieSession",
"commands":[
{
"insert":{
"out-identifier":"TestAdvance",
"object":{
"LoanAdvance":{
"tenure":4,
"isBlacklisted":false
}
}
}
},
{
"insert":{
"out-identifier":"TestAdvance",
"object":{
"LoanAdvance":{
"tenure":3,
"isBlacklisted":false
}
}
}
},
{
"fire-all-rules":{
}
}
]
}
}
My rule in guided decision table looks like this:
I want to make a REST request to the rule engine and get the result set as a list.
Please confirm if my JSON request is correct. Or is there any better way to achieve the same?
Any help would be appreciated.
Thanks & Regards
you are using incorrect json request format. With JSON request payload no need to use ''batch-execution", remove that. And correct JSON request will look like as:
{
"commands":[
{
"insert":{
"out-identifier":"obj",
"object":{
"example.project4_91839699.Person":{
"firstName":"abc",
"lastName":"abc",
"hourlyRate":22,
"wage":100
}
}
}
},{
"insert":{
"out-identifier":"obj2",
"object":{
"example.project4_91839699.Person":{
"firstName":"xyz",
"lastName":"xyz",
"hourlyRate":24,
"wage":100
}
}
}
}
{
"fire-all-rules":""
}
]
}

Why ionic Network Plugin is not working after upgrading.?

This code was working fine till upgrade to ionic 3.4.
now in serve command shows :
Property 'connection' does not exist on type 'Navigator'.
I've replaced this code Network.connection with navigator.connection but still the same result.
export class NetworkService {
onDevice: boolean;
constructor(public platform: Platform , private Network: Network){
this.onDevice = this.platform.is('cordova');
}
isOnline(): boolean {
if(this.onDevice && Network.connection){
return Network.connection !== Connection.NONE;
} else {
return navigator.onLine;
}
}
isOffline(): boolean {
if(this.onDevice && Network.connection){
return Network.connection === Connection.NONE;
} else {
return !navigator.onLine;
}
}
}
The wrapper around that plugin has changed and doesn't expose a 'connection' property. Instead you need to use 'type' property. Full example available on the ionic documentation here.

Meteor + React: Can't get data from mongoDB Collection

I have a Meteor Application that I'm developing with React. I still have the autopublish package in my project (autopublish#1.0.7).
Here is my relevant code:
MainMenu.jsx
import React, { Component, PropTypes } from 'react'
import { Meteor } from 'meteor/meteor'
import { FlowRouter } from 'meteor/kadira:flow-router'
import { createContainer } from 'meteor/react-meteor-data'
import { ChatRooms } from '/imports/api/chatrooms.js'
export class MainMenu extends Component {
render() {
console.log(this.props.chatrooms)
return (
{/* Render stuff here is not part of the scope of this question */}
)
}
}
MainMenu.PropTypes = {
chatrooms: PropTypes.array.isRequired
}
export default createContainer(() => {
return {
chatrooms: ChatRooms.find({}).fetch()
}
}, MainMenu)
chatrooms.js
import { Mongo } from 'meteor/mongo'
export const ChatRooms = new Mongo.Collection('chatrooms')
The console.log(this.props.chatrooms) in the MainMenu Component always returns an empty array ([]).
There are definitely items in the Mongo Database because when I run the meteor mongo command in my console and type db.chatrooms.find({}); it returns the 3 items that I've inserted to test this all.
Anyone have any idea what I may be doing wrong here? Help would be much appreciated!
I've figured it out. I left out a crucial step of this whole process.
In my /server/main.js file I needed to add the following line which fixed everything:
import '../imports/api/chatrooms.js