Nautilus: Pelagic Mollusc

npm

Need private packages and team management tools?Check out npm Orgs. »

@sharyn/shared

4.5.2 • Public • Published

🌹 @sharyn/shared

npm

This package provides isomorphic / universal utilities than can be used on both the client and the server.

🌹 Install

yarn add @sharyn/shared

🌹 Usage

Switch

import Switch from '@sharyn/shared/Switch'
import FooPage from 'foo/cmp-page/foo-page'
import FooIcon from '@material-ui/icons/Foo'
 
export const fooRoute: Object = {
  path: '/foo',
  exact: true,
  loggedInOnly: true,
  title: 'Foo',
  Icon: FooIcon,
  inNav: true,
}
 
const routesAndCmps = [
  { route: fooRoute, component: FooPage }
  { route: barRoute, component: BarPage }
]
 
const App = () => (
  <Switch routesAndCmps={routesAndCmps} />
)

fetchGraphql (don't use it)

// ...
 
const query = "query ($id: ID!) { getThing(id: $id) { id } }"
const variables = { id: 123 }
 
const resp = await fetchGraphql({ query, variables })
 
/*
  {
    data: {
      getThing: { id: 123 }
    },
    errors: [...]
  }
*/

Options

fetchGraphql(options, fetchOptions)

  • options is an object than can contain:

    • query (required): The GraphQL query.
    • variables: The object of your variables.
    • host: The host (https://www.example.com:12345). Leave this field empty for client-side fetches.
    • path: The GraphQL path (default is /graphql)
    • cookie: A cookie string (useful for server-side fetches).
  • fetchOptions is the native options of fetch in case you need to override the defaults provided by fetchGraphql.

Keywords

none

install

npm i @sharyn/shared

Downloadsweekly downloads

121

version

4.5.2

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability