Import GraphQL operations from one project into another

Is it possible to import operations from one project into another?

I have a monorepo with 2 different instances of Wundergraph. One for internal use with a custom authentication provider. A second one that is public. Some operations are the same in both.

Is it possible to somehow share them?


What exactly you’d like to share? What’s the goal of sharing? How should it be used?

I would like to share some of the .graphql files.

For security reasons a bunch of operations can’t be exposed to the public internet. Even behind authentication.
Currently we have two Wundergraph instances. One for the internal network and another one on the internet.

A few GraphQL operations are the same in both projects. Right now, I have the same .graphql file in both of them. If there was an option to import I could create a shared project and have the shared queries, mutations and fragments in only one place.

Something like:

#import from '…/…/sharedProject/myquery.graphql

#import from '…/…/sharedProject/myquery.graphql


query {
   myQuery {

What would you say when you can specify in the WunderGraph config additional directories to look at for operations?

E.g. you specify a path and maybe even a function to filter.

Yes. That would work.

Any additional info that I might be missing to implement this feature?

I can’t think of anything else.

Allowing the user to add/change the operations folder path in the wundergraph.operations.ts would work better than my initial suggestion. This way we could share everything internalOperations, fragments, queries, mutations and typescript operations.

Something like:

import { configureWunderGraphOperations } from '@wundergraph/sdk';
import type { OperationsConfiguration } from './generated/wundergraph.operations';

export default configureWunderGraphOperations<OperationsConfiguration>({
	operations: {
		defaultConfig: {			
			operationsFolderPath: ['./operations', '../../sharedOperations'] // default value ['./operations']
                        authentication: {
				required: false,
		queries: (config) => ({
			caching: {
				enable: false,
				staleWhileRevalidate: 60,
				maxAge: 60,
				public: true,
			liveQuery: {
				enable: true,
				pollingIntervalSeconds: 1,
		mutations: (config) => ({
		subscriptions: (config) => ({
		custom: {},


1 Like