solui
  • Dapps
  • Getting Started
  • Docs
  • Community

@solui/graphql

GraphQL utilities for solUI:

  • Queries and mutations for interacting with backend.
  • Method to setup a new client instance.
  • Authentication handling logic.
  • Error handling utilities.

Installation

npm install @solui/graphql

Example usage

Search for packages by keyword:

const { createApolloClient, SearchQuery } = require('@solui/graphql')

const client = createApolloClient({
  endpoint: `https://solui.dev/api/graphql`,
  name: 'my-client',
  version: '1.0.0',
})

// search for package by keyword
const { data: { search } } = await client.query({
  query: SearchQuery,
  fetchPolicy: 'cache-and-network',
  variables: {
    criteria: {
      keyword: 'erc20'
    }
  }
})

// output results
console.log(search)

For a full list of queries please see the GraphQL schema.

Read full documentation.

## License

Copyright 2019 solUI Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

stringifyError

Stringify given GraphQL request error.

Parameters

  • err any Error from GraphQL call.

Returns String

ErrorFragment

Error.

Type: Fragment

AuthTokenFragment

Auth token.

Type: Fragment

UserFragment

User.

Type: Fragment

UserProfileFragment

User profile.

Type: Fragment

LoginResultFragment

Login result.

Type: Fragment

ReleaseFragment

Release.

Type: Fragment

AuthTokenResultFragment

Auth token result.

Type: Fragment

ReleaseListFragment

Release list.

Type: Fragment

ReleaseResultFragment

Release result.

Type: Fragment

ReleaseListResultFragment

Release list result.

Type: Fragment

PublishFinalizeFragment

Publish finalization.

Type: Fragment

PublishSuccessFragment

Publish success.

Type: Fragment

PublishResultFragment

Publish result.

Type: Fragment

PublishToChainSuccessFragment

Publish-to-chain success.

Type: Fragment

PublishToChainResultFragment

Publish-to-chain result.

Type: Fragment

DappChainInfoFragment

DappChainInfo.

Type: Fragment

DappChainInfoResultFragment

DappChainInfoResult.

Type: Fragment

createApolloClient

Create a new Apollo GraphQL client for talking to the solUI API.

Parameters

  • $0 Object
    • $0.endpoint
    • $0.authTokenImplementation
    • $0.name
    • $0.version
    • $0.extraClientOptions ...any
  • endpoint String Server graphql endpoint.
  • authTokenImplementation Object Auth token manager implementation.
  • name String Client name (to identify itself to server)
  • version String Client version.

Returns ApolloClient

PublishMutation

Publish package.

Type: Mutation

LoginMutation

Login user.

Type: Mutation

GetAllReleases

Get all releases.

Type: Query

GetMyReleasesQuery

Get my releases.

Type: Query

GetReleaseQuery

Get a release.

Type: Query

GetAuthTokenQuery

Get authentication token.

Type: Query

GetMyProfile

Get my profile.

Type: Query

GetMyProfileWithoutAuth

Get my profile without authentication (authentation will have to manually provided at call-time).

Type: Query

GetDappInfoFromChain

Get dapp info from on-chain repo.

Type: Query

getTypeDefs

Get GraphQL type definitions.

Returns GraphQLTypeDef

buildAuthHeaders

Build auth headers for sending with GraphpQL requests.

Parameters

  • token String Authentication token

Returns Object Headers as key-value pairs.