All Projects → apollographql → Apollo Scalajs

apollographql / Apollo Scalajs

Licence: mit
Use Apollo GraphQL from Scala.js apps!

Programming Languages

scala
5932 projects
scalajs
39 projects

Projects that are alternatives of or similar to Apollo Scalajs

Guide To Graphql
A Frontend Developer's Guide to GraphQL (Fluent Conf 2018)
Stars: ✭ 59 (-28.92%)
Mutual labels:  graphql, apollo
Apollo Prophecy
🔮 GraphQL error management made Easy, generate custom machine-readable errors for Apollo Client/Server from the CLI
Stars: ✭ 83 (+0%)
Mutual labels:  graphql, apollo
Apollo Link Sentry
Apollo Link middleware which enriches SentryJS with GraphQL data
Stars: ✭ 63 (-24.1%)
Mutual labels:  graphql, apollo
Blaze Apollo
Blaze integration for the Apollo Client
Stars: ✭ 56 (-32.53%)
Mutual labels:  graphql, apollo
Nestjs Cqrs Starter
NestJS CQRS Microservices Starter Project
Stars: ✭ 80 (-3.61%)
Mutual labels:  graphql, apollo
Erxes Api
API for erxes
Stars: ✭ 57 (-31.33%)
Mutual labels:  graphql, apollo
Artemis Dev Tool
An Apollo GraphQL Query Schema Testing Tool
Stars: ✭ 66 (-20.48%)
Mutual labels:  graphql, apollo
Apollo Invalidation Policies
An extension of the Apollo 3 cache with support for type-based invalidation policies.
Stars: ✭ 55 (-33.73%)
Mutual labels:  graphql, apollo
Apollo Upload Client
A terminating Apollo Link for Apollo Client that allows FileList, File, Blob or ReactNativeFile instances within query or mutation variables and sends GraphQL multipart requests.
Stars: ✭ 1,176 (+1316.87%)
Mutual labels:  graphql, apollo
Apollo Mocked Provider
Automatically mock GraphQL data with a mocked ApolloProvider
Stars: ✭ 70 (-15.66%)
Mutual labels:  graphql, apollo
Subscriptions Transport Sse
A Server-Side-Events (SSE) client + server for GraphQL subscriptions
Stars: ✭ 55 (-33.73%)
Mutual labels:  graphql, apollo
Nextjs Strapi Boilerplate
🎨 Boilerplate for building applications using Strapi and Next.js
Stars: ✭ 76 (-8.43%)
Mutual labels:  graphql, apollo
Apollo Cache Persist
🎏 Simple persistence for all Apollo Cache implementations
Stars: ✭ 1,078 (+1198.8%)
Mutual labels:  graphql, apollo
Next React Graphql Apollo boostrap
React + GraphQL + Next.js project architecture that I play with right now
Stars: ✭ 59 (-28.92%)
Mutual labels:  graphql, apollo
A Pop
🎶 HD Music Streaming and Sharing Web App
Stars: ✭ 55 (-33.73%)
Mutual labels:  graphql, apollo
Cynthesize Frontend
Frontend written in Angular 7 and deployed GraphQL for Cynthesize. Development build: https://cynthesize-develop.netlify.com
Stars: ✭ 65 (-21.69%)
Mutual labels:  graphql, apollo
Graphql Upload
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
Stars: ✭ 1,071 (+1190.36%)
Mutual labels:  graphql, apollo
Laravel Vuejs.com
Laravel and VueJs Blog, using Laravel nova, GraphQL, NuxtJs, Apollo and ...more
Stars: ✭ 54 (-34.94%)
Mutual labels:  graphql, apollo
Apollo Server Vercel
⚫ Production-ready Node.js GraphQL server for Vercel Serverless Functions
Stars: ✭ 69 (-16.87%)
Mutual labels:  graphql, apollo
React Hipstaplate
A ReactJS full-stack boilerplate based on typescript with ssr, custom apollo-server and huge stack of modern utilities which will help you to start your own project
Stars: ✭ 74 (-10.84%)
Mutual labels:  graphql, apollo

Apollo Scala.js

use Apollo Client and React Apollo from your Scala.js apps!

View the docs

Installation

Add the dependency to your build.sbt

resolvers += "Apollo Bintray" at "https://dl.bintray.com/apollographql/maven/"
libraryDependencies += "com.apollographql" %%% "apollo-scalajs-core" % "0.8.0" // if you are writing a vanilla Scala.js app
libraryDependencies += "com.apollographql" %%% "apollo-scalajs-react" % "0.8.0" // if you are writing a React Scala.js app

You probably also want to add other Slinky modules such as the web module, so check out the instructions at https://slinky.dev

To set up the code generator, which uses the Apollo CLI to generate static types for your GraphQL queries, first install apollo npm i -g apollo

and then set up SBT to automatically run it

val namespace = "your package here"

(sourceGenerators in Compile) += Def.task {
  import scala.sys.process._

  val out = (sourceManaged in Compile).value

  out.mkdirs()

  Seq(
    "apollo", "client:codegen", s"--queries=${((sourceDirectory in Compile).value / "graphql").getAbsolutePath}/*.graphql",
    s"--localSchemaFile=${(baseDirectory.value / "schema.json").getAbsolutePath}",
    "--target=scala",
    s"--namespace=$namespace",
    graphQLScala.getAbsolutePath
  ).!

  Seq(out / "graphql.scala")
}

Usage

Once you have placed some GraphQL queries in src/main/graphql, you can use the generated types to create GraphQL-powered React components!

To integrate GraphQL data in your React tree, simply use the Query component to render subtrees based on a specified query.

Query(UsdRatesQuery)  { queryStatus =>
  if (queryStatus.loading) "Loading..."
  else if (queryStatus.error) s"Error! ${queryStatus.error.message}"
  else {
    div(queryStatus.data.get.rates.mkString(", "))
  }
}

For more on implementing advanced components, follow the instructions at https://slinky.shadaj.me

Next, to initialize Apollo Client in your application, first create an instance of the client (here using Apollo Boost)

val client = ApolloBoostClient(
  uri = "https://graphql-currency-rates.glitch.me"
)

Finally, wrap your React component tree inside an ApolloProvider component, which all components inside to perform GraphQL queries with the specified client

ApolloProvider(client)(
  ...
)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].