Fork me on GitHub

hi, i’m using it


had to make a few hacks to get it to where it did what i needed


i hacked my services.clj as follows

(defn dynamic-schema
  ;(pp/pprint "IN dyn")
  ;(pp/pprint (resolver-map))
  (-> "resources/graphql/schema.edn"
      (attach-resolvers (resolver-map))

(defonce compiled-schema

(defn execute-request [rawbody]
  (let [parsed  (format-params rawbody)
        query   (:query parsed)
        vars    (:variables parsed)
        context nil
        schema  (if (:dev env) (dynamic-schema) compiled-schema)]

    (-> (lacinia/execute schema query vars context)


This allows for reloading the schema per request when you’re in dev mode, pulls out the query, vars, etc from the request, and ensures the response goes back as json as opposed to a string. There are some additional functions like merge-custom-scalars that I added for my needs


I also had to change the default graphiql page as it wasn’t sending the variables, etc

function graphQLFetcher(graphQLParams) {
        return fetch(window.location.origin + '/api' , {
          method: 'post',
          headers: {
            'Content-Type': 'application/json'
            // 'apikey': 'graphiql'
		  body: JSON.stringify(graphQLParams)
THe above got things working for me


Hmm. I think something's a bit funky about the changes on one side or the other. format-params is throwing an error (`ERROR compojure.api.exception - JSON error (unexpected character): q`). The query it's receiving is "query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name }}}}}}}} ". That's on initial load of the graphiql page; I haven't entered an actual query yet. Is it immediately obvious to you what's going on there? BTW I didn't add dynamic-schema yet, since I don't have any custom scalars (and I assume that merge-custom-scalars is a fn in your code; I didn't find it in lacinia). Otherwise I'm following your suggestion word-for-word.


I should add that the same error is thrown before and after I make the suggested changes to the graphiql page.


Certainly doesn't seem like valid JSON, but it's not quite clear to me that it needs to be; it seems like we're just using JSON to do the string wrapping.


@eoliphant that’s a big help! Looking forward to incorporating it later this morning. Thanks tons for the extensive answer!


no prob, i was planning to make a PR for these changes at some point