# -*- encoding: utf-8 -*- # stub: wcc-contentful-graphql 1.0.3 ruby lib Gem::Specification.new do |s| s.name = "wcc-contentful-graphql".freeze s.version = "1.0.3".freeze s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.metadata = { "documentation_uri" => "https://watermarkchurch.github.io/wcc-contentful/1.0/wcc-contentful-graphql" } if s.respond_to? :metadata= s.require_paths = ["lib".freeze] s.authors = ["Watermark Dev".freeze] s.date = "2021-11-17" s.description = "GraphQL interface over WCC::Contentful store".freeze s.email = ["dev@watermark.org".freeze] s.files = [".rspec".freeze, "Guardfile".freeze, "README.md".freeze, "Rakefile".freeze, "doc".freeze, "lib/wcc/contentful/ext/services.rb".freeze, "lib/wcc/contentful/graphql.rb".freeze, "lib/wcc/contentful/graphql/builder.rb".freeze, "lib/wcc/contentful/graphql/federation.rb".freeze, "lib/wcc/contentful/graphql/federation/builds_arguments.rb".freeze, "lib/wcc/contentful/graphql/federation/namespaces_types.rb".freeze, "lib/wcc/contentful/graphql/field_helper.rb".freeze, "lib/wcc/contentful/graphql/types.rb".freeze, "lib/wcc/contentful/graphql/version.rb".freeze, "wcc-contentful-graphql.gemspec".freeze] s.homepage = "https://github.com/watermarkchurch/wcc-contentful/wcc-contentful-graphql".freeze s.licenses = ["MIT".freeze] s.required_ruby_version = Gem::Requirement.new(">= 2.3".freeze) s.rubygems_version = "3.5.10".freeze s.summary = "[![Gem Version](https://badge.fury.io/rb/wcc-contentful-graphql.svg)](https://rubygems.org/gems/wcc-contentful-graphql) [![Build Status](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful) [![Coverage Status](https://coveralls.io/repos/github/watermarkchurch/wcc-contentful/badge.svg?branch=master)](https://coveralls.io/github/watermarkchurch/wcc-contentful?branch=master) # WCC::Contentful::Graphql This gem creates a GraphQL schema over your configured [data store](https://www.rubydoc.info/gems/wcc-contentful#Store_API). You can execute queries against this GraphQL schema to get all your contentful data. Under the hood, queries are executed against your backing store to resolve all the requested data. ### Important note! The GraphQL schema currently does not utilize the \"include\" parameter, so it is a very good idea to configure your store to either `:eager_sync` or `:lazy_sync`. If you don't do this, you will see a lot of requests to Contentful for specific entries by ID as the GraphQL resolver walks all your links! [More info on configuration can be found here](https://www.rubydoc.info/gems/wcc-contentful/WCC%2FContentful%2FConfiguration:store=) ## Usage Querying directly within your app ```rb schema = WCC::Contentful::Services.instance.graphql_schema => # result = schema.execute(<<~QUERY) { allConference(filter: { code: { eq: \"CLC2020\" } }) { title startDate code } } QUERY GET https://cdn.contentful.com/spaces/xxxxx/entries?content_type=conference&fields.code.en-US=CLC2020&locale=%2A Status 200 => #{\"allConference\"=>[{\"title\"=>\"Church Leaders Conference\", \"startDate\"=>\"2020-04-28\", \"code\"=>\"CLC2020\"}]}}> result.to_h => {\"data\"=> {\"allConference\"=> [{\"title\"=>\"Church Leaders Conference\", \"startDate\"=>\"2020-04-28\", \"code\"=>\"CLC2020\"}]}} ``` Setting up a controller to respond to GraphQL queries ```rb class Api::GraphqlController < Api::BaseController include WCC::Contentful::ServiceAccessors skip_before_action :authenticate_user!, only: :query def query result = graphql_schema.execute( params[:query], variables: params[:variables] ) render json: result end end ``` ## Advanced Configuration ### Including your Contentful schema inside another GraphQL schema ```rb QueryType = GraphQL::ObjectType.define do # extend this to get 'schema_stitch' extend WCC::Contentful::Graphql::Federation name 'RootQuery' field 'a', types.String schema_stitch(WCC::Contentful::Services.instance.graphql_schema, namespace: 'contentful') end Schema = GraphQL::Schema.define do query QueryType resolve_type ->(type, obj, ctx) { raise StandardError, \"Cannot resolve type \#{type} \#{obj.inspect} \#{ctx.inspect}\" } end File.write('schema.gql', GraphQL::Schema::Printer.print_schema(Schema)) ``` results in... ```gql schema { query: RootQuery } type Contentful { \"\"\" Find a Asset \"\"\" Asset(_content_type: Contentful_StringQueryOperatorInput, description: Contentful_StringQueryOperatorInput, id: ID, title: Contentful_StringQueryOperatorInput): Contentful_Asset \"\"\" Find a CallToAction \"\"\" CallToAction(_content_type: Contentful_StringQueryOperatorInput, id: ID, internalTitle: Contentful_StringQueryOperatorInput, style: Contentful_StringQueryOperatorInput, text: Contentful_StringQueryOperatorInput, title: Contentful_StringQueryOperatorInput): Contentful_CallToAction ... ``` ### Limiting the schema to only a few fields ```rb store = WCC::Contentful::Services.instance.store builder = WCC::Contentful::Graphql::Builder.new( WCC::Contentful.types, store, ).configure do root_types.slice!('conference') schema_types['conference'].define do # change the types of some fields, undefine fields, etc... end end @schema = builder.build_schema ```".freeze s.specification_version = 4 s.add_development_dependency(%q.freeze, [">= 0".freeze]) s.add_development_dependency(%q.freeze, ["~> 2.2".freeze]) s.add_development_dependency(%q.freeze, ["~> 1.0".freeze]) s.add_development_dependency(%q.freeze, ["~> 10.0".freeze]) s.add_development_dependency(%q.freeze, ["~> 3.0".freeze]) s.add_development_dependency(%q.freeze, ["~> 0.3.0".freeze]) s.add_development_dependency(%q.freeze, ["= 0.68".freeze]) s.add_development_dependency(%q.freeze, ["~> 0.16.1".freeze]) s.add_development_dependency(%q.freeze, ["~> 3.0".freeze]) s.add_development_dependency(%q.freeze, ["~> 2.14".freeze]) s.add_development_dependency(%q.freeze, ["~> 4.7".freeze]) s.add_development_dependency(%q.freeze, ["~> 1.3.0".freeze]) s.add_development_dependency(%q.freeze, ["~> 0.7.1".freeze]) s.add_development_dependency(%q.freeze, ["~> 0.9.4".freeze]) s.add_development_dependency(%q.freeze, ["~> 1.3.6".freeze]) s.add_development_dependency(%q.freeze, ["~> 0.9.1".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 1.7".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 1.0.3".freeze]) end