![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ember-graphql-adapter
Advanced tools
A Ember CLI adapter for using GraphQL with Ember Data.
ember install ember-graphql-adapter
Create your adapter first
// app/adapters/post.js
import GraphQLAdapter from 'ember-graphql-adapter';
export default GraphQLAdapter.extend({
endpoint: `${EmberENV.apiBaseUrl}/graph`
});
Now define your serializer
// app/serializers/post.js
import { Serializer } from 'ember-graphql-adapter';
export default Serializer.extend({});
And you're done!
coalesceFindRequests: true
By using the fantastic graphql gem, you can expose your relational database as a GraphQL endpoint.
We start by creating a new type
# app/models/graph/post_type.rb
module Graph
PostType = GraphQL::ObjectType.define do
name "Post"
description "A post"
field :id, types.ID
field :name, types.String
end
end
Then we create the query type
# app/models/graph/query_type.rb
module Graph
QueryType = GraphQL::ObjectType.define do
name "Query"
description "The query root of this schema"
field :post do
type PostType
argument :id, !types.ID, "The ID of the post"
resolve -> (obj, args, ctw) do
Post.find(args[:id])
end
end
end
end
After that, it's time for the mutation type
# app/models/graph/mutation_type.rb
module Graph
MutationType = GraphQL::ObjectType.define do
name "Mutation"
description "Mutations"
field :postCreate do
type PostType
argument :name, !types.String, "The post name"
resolve -> (obj, args, ctw) do
Post.create(name: args[:name])
end
end
end
end
Now, we can build the whole schema
# app/models/graph/schema.rb
module Graph
Schema = GraphQL::Schema.new(
query: Graph::QueryType,
mutation: Graph::MutationType
)
end
In the controller we just delegate to the GraphQL schema
# app/controllers/graph_controller.rb
class GraphController < ApplicationController
def index
render json: ::Graph::Schema.execute(
params.fetch("query"),
context: {} # you can pass the current_user here
)
end
end
Finally, we just expose the GraphQL endpoint in the route
# config/routes.rb
get 'graph', to: 'graph#index'
And that's it!
git clone https://github.com/alphasights/ember-graphql-adapter.git
npm install && bower install
ember server
ember test --server
ember build
FAQs
An Ember CLI adapter for GraphQL
The npm package ember-graphql-adapter receives a total of 6 weekly downloads. As such, ember-graphql-adapter popularity was classified as not popular.
We found that ember-graphql-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.