Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(graph): allow sharing VCS branches through a lockfile #4899

Merged
merged 7 commits into from Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands/graph/graph-edit.js
Expand Up @@ -48,6 +48,7 @@ const graphEdit = async (options, command) => {
netlifyToken,
site,
state,
netlifyGraphConfig,
})

const { branch } = gitRepoInfo()
Expand Down
3 changes: 3 additions & 0 deletions src/commands/graph/graph-init.js
Expand Up @@ -5,6 +5,7 @@ const { OneGraphClient } = require('netlify-onegraph-internal')
const { v4: uuidv4 } = require('uuid')

const { OneGraphCliClient, ensureCLISession } = require('../../lib/one-graph/cli-client')
const { getNetlifyGraphConfig } = require('../../lib/one-graph/cli-netlify-graph')
const { NETLIFYDEVERR, chalk, error, exit, getToken, log } = require('../../utils')
const { msg } = require('../login/login')

Expand Down Expand Up @@ -63,11 +64,13 @@ const graphInit = async (options, command) => {

await ensureAppForSite(netlifyToken, siteId)

const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options })
await ensureCLISession({
metadata: {},
netlifyToken,
site,
state,
netlifyGraphConfig,
})

let envChanged = false
Expand Down
16 changes: 15 additions & 1 deletion src/commands/graph/graph-library.js
@@ -1,4 +1,5 @@
// @ts-check
const { readLockfile } = require('../../lib/one-graph/cli-client')
const {
buildSchema,
defaultExampleOperationsDoc,
Expand All @@ -9,7 +10,7 @@ const {
readGraphQLOperationsSourceFile,
readGraphQLSchemaFile,
} = require('../../lib/one-graph/cli-netlify-graph')
const { error, log } = require('../../utils')
const { NETLIFYDEVERR, chalk, error, log } = require('../../utils')

/**
* Creates the `netlify graph:library` command
Expand Down Expand Up @@ -42,10 +43,23 @@ const graphLibrary = async (options, command) => {
const parsedDoc = parse(currentOperationsDoc)
const { fragments, functions } = extractFunctionsFromOperationDoc(parsedDoc)

const lockfile = readLockfile({ siteRoot: command.netlify.site.root })

if (lockfile == null) {
error(
`${NETLIFYDEVERR} Error: no lockfile found, unable to run \`netlify graph:library\`. To pull a remote schema (and create a lockfile), run ${chalk.yellow(
'netlify graph:pull',
)} `,
)
}

const schemaId = lockfile && lockfile.locked.schemaId

generateFunctionsFile({
logger: log,
netlifyGraphConfig,
schema,
schemaId,
operationsDoc: currentOperationsDoc,
functions,
fragments,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/graph/graph-pull.js
Expand Up @@ -106,7 +106,7 @@ const graphPull = async (options, command) => {
const createGraphPullCommand = (program) =>
program
.command('graph:pull')
.description('Pull down your local Netlify Graph schema, and process pending Graph edit events')
.description('Pull your remote Netlify Graph schema locally, and process pending Graph edit events')
.action(async (options, command) => {
await graphPull(options, command)
})
Expand Down