Giter Site home page Giter Site logo

Persisted Queries about houdini HOT 3 CLOSED

houdinigraphql avatar houdinigraphql commented on August 20, 2024
Persisted Queries

from houdini.

Comments (3)

AlecAivazis avatar AlecAivazis commented on August 20, 2024

Its definitely something that I would love to see in houdini, just forgot to create the issue 😅

from houdini.

pixelmund avatar pixelmund commented on August 20, 2024

Thinking about this some more, we could probably use a relay like approach where we create a output file queryMap.json customizable with an cli flag e.g. --persist-output ./src/some_folder/queryMap.json with the artifact hash as key and the query as value. We could then pass the artifact or some form to the environments fetchFunction instead of only text and variables. From there some could simply pass documentId (the artifact hash) instead of the full query.

export default new Environment(async function (operation) {
	// send the request to the api
	const result = await this.fetch('/graphql', {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json',
		},
		body: JSON.stringify({
			// query: operation.text,
			variables: operation.variables,
                        documentId: operation.hash		
            }),
	})

	// parse the result as json
	return await result.json()
})

We could then probably set the raw field in generated artifacts to null if we're persisting queries, but i'm not sure.

  • Where are queries getting hashed? hashDocument doesn't seem to be used.

from houdini.

AlecAivazis avatar AlecAivazis commented on August 20, 2024

Awesome - in general the approach seems like the right one. I think it's probably more likely that the user is going to follow the standard that urql and apollo both follow which can be found here but I don't think that really matters from our perspective. As long as a hash gets generated and attached to the artifact in a way that the environment has access to when making queries, the user can make that decision for themselves.

Also, hashDocument isn't used any more but I left it in the codebase in case we needed it. It's a remnant from when the preprocessor import the artifacts but that's no longer the case.

from houdini.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.